-
-
Notifications
You must be signed in to change notification settings - Fork 2
Open
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
Metadata
Metadata
Assignees
Labels
No labels