You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, when an unhandled exception is thrown in NativeScript (inside app-code, core-modules or plugins) it will (in most) cases crash the application showing the error and stack trace.
When in development - in many cases this is what you'd expect. You would want to have the stack-trace of the exact location the unexpected behavior has occurred, so that you can more easily understand what happened and fix it.
However, in production, an application crash can seriously hurt you application credibility and drive away customers. In many cases you might prefer anything else (app freeze, blank screen, failed navigation etc.) to an actual crash with an error log. There are even cases, in whitch the application will recover and will work OK even if something unexpected has happened - for exampled failed animation or a typo in CSS property.
Proposal
The aim of this FR is to propose an API that provides a way to handle errors in different ways in development and in production. It should provide flexibility to configure how errors should be handled. For example:
(development 1) Throw exceptions as soon as error occurs.
(development 2) Show a scary console.log with ERROR: Something bad happened but continue execution of the app. You will see it in you terminal, but decide if it is critical based on what happens with the app after that.
(production) Send an error report to your analytics/error-report server, but continue app execution. Maybe triggers some recover logic that will handle the app without a crash.
API Proposal
Extend the trace module with an error() method.
Use the method in core-framework/plugins/app code:
function doSomething(arg) {
// Instead of
if(!arg) throw new Error("Arg not provided in "doSomething");
// Use trace.error()
if(!arg) {
trace.error("Arg not provided in "doSomething");
return;
}
// ... implementation using arg
}
Developers can define custom error handler logic (probably on app startup):
Uh oh!
There was an error while loading. Please reload this page.
The Problem
Currently, when an unhandled exception is thrown in NativeScript (inside app-code, core-modules or plugins) it will (in most) cases crash the application showing the error and stack trace.
When in development - in many cases this is what you'd expect. You would want to have the stack-trace of the exact location the unexpected behavior has occurred, so that you can more easily understand what happened and fix it.
However, in production, an application crash can seriously hurt you application credibility and drive away customers. In many cases you might prefer anything else (app freeze, blank screen, failed navigation etc.) to an actual crash with an error log. There are even cases, in whitch the application will recover and will work OK even if something unexpected has happened - for exampled failed animation or a typo in CSS property.
Proposal
The aim of this FR is to propose an API that provides a way to handle errors in different ways in development and in production. It should provide flexibility to configure how errors should be handled. For example:
console.log
withERROR: Something bad happened
but continue execution of the app. You will see it in you terminal, but decide if it is critical based on what happens with the app after that.API Proposal
Extend the
trace
module with anerror()
method.Use the method in core-framework/plugins/app code:
Developers can define custom error handler logic (probably on app startup):
Next Steps
tns-core-modules
.Ping @NathanWalker @EddyVerbruggen
The text was updated successfully, but these errors were encountered: