NativeScript / NativeScript/napi-android
optional way of automatic native exception wrapping
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C++
- Sterne
- 33
- Forks
- 3
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Es werden keine Dateien, Tests oder Einstiegspunkte genannt. Beginne damit, die native Ausnahmebehandlung in der Android runtime zu lokalisieren und zu ermitteln, wie Laufzeitoptionen konfiguriert werden. Als abgeschlossen gilt die Arbeit, wenn ein optionales, standardmäßig deaktiviertes Verhalten einen JavaScript Error mit der nativen Ausnahme und dem Stacktrace erzeugt, wenn eine native Ausnahme catch erreicht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- android, cpp, javascript, typescript
- Bereich
- developer-experience, mobile-dev
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100