optional way of automatic native exception wrapping
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 25/100
- Type d'issue
- Fonctionnalité
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- android, cpp, javascript, typescript
- Domaine
- developer-experience, mobile-dev
Piste de recherche
Aucun fichier, test ou point d’entrée n’est indiqué. Commencez par localiser la gestion native des exceptions dans l’Android runtime et identifier comment les options d’exécution sont configurées. Le travail est terminé lorsqu’un comportement facultatif, désactivé par défaut, produit un JavaScript Error avec l’exception native et la stack trace lorsqu’une exception native atteint catch.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- C++
- Étoiles
- 33
- Forks
- 3
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de NativeScript/napi-android
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
NativeScript/napi-android#37 · 7 commentaires ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
NativeScript/napi-android#30 ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 42/100
NativeScript/napi-android#28 ·
-
Handle regular JS Errors Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 20/100
NativeScript/napi-android#25 ·
-
Debug and fix memory leaks Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
NativeScript/napi-android#20 ·
Toutes les issues de NativeScript/napi-android
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
duckdb/duckdb-wasm#2258 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
objectionary/eo-graphs#75 ·
-
Coarray integration tests carry no LABELS, so run_tests.py silently skips them under every backend Ouvertecoarray
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
FISCO-BCOS/FISCO-BCOS#5642 ·