[Scarpet bug/suggestion] Uncatched exceptions (throw) don't throw a stacktrace
altrisi opened this issue ยท 2 comments
Currently, an unhandled throw()
call terminates the execution of the script, without giving any extra information than changing the return value. In my opinion, it should throw a proper error (with a stacktrace) instead.
As an example of where this could be useful, while throw()
may not be used too much, in case the throw()
may come from a library and the function throwing the error being in an event, it can make the function silently fail, since only the return value will change and nothing will be shown or logged anywhere (except if explicitly logged, but the lib may suppose the exception would be caught). In the same case of an external library, but in this case happening in a command and the exception not being thrown in every call, the end-user may be confused by some random return that may be completely unrelated to the command they were typing.
It would also be a nice way to force displaying a stacktrace without trying to execute incorrect code (this is my case, the rest are hypothetical situations).
well, unhandled throw() warrants an error message, but (scarpet) stacktrace will not be able to be retrieved as its tracked only when programming errors are thrown. Simply when the value is caught at the end - it doesn't carry the scarpet stack information, and passing it with every throw() just in case is not a good idea.
I agree that unhandled throws() should result in an error message. exit() is to do that without the error message