NativeScript / NativeScript/napi-android

optional way of automatic native exception wrapping

オープン
#31 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
C++
スター
33
フォーク
3
PR マージ指標
30日以内にマージされた PR はありません

説明

Right now in the runtimes when a native exception is thrown which you catch with a try/catch it is the native exception object that you get.
So in my apps/N fork i use something like this:

export function wrapNativeException<T = any>(ex: NSError, wrapError: (...args) => T = (msg) => new Error(msg) as any) {
	if (!ex) {
		return;
	}
	if (typeof ex === 'string') {
		return wrapError(ex);
	}
	if (!(ex instanceof Error)) {
		const err = wrapError(ex.toString());
		err['nativeException'] = ex;
		//@ts-ignore
		err['stackTrace'] = com.tns.NativeScriptException.getStackTraceAsString(ex);
		return err;
	}
	return ex;
}

That method wraps the native exception in a JS error with stackTrace.

Would be pretty awesome to have that done automatically so that the error object you get in catch is an actual JS Error.
I think for now if we can do it it should be optional and disabled by default

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

ファイル、テスト、またはエントリーポイントは指定されていません。まず Android runtime 内のネイティブ例外処理を見つけ、runtime オプションの設定方法を特定します。ネイティブ例外が catch に到達したとき、オプションでデフォルトでは無効な動作によって、ネイティブ例外とスタックトレースを含む JavaScript Error が生成されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
android, cpp, javascript, typescript
領域
developer-experience, mobile-dev
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。