When you throw an exception in Dart (assuming you don't catch it) the program execution will end showing you the exception and the stack trace. I was wondering if there is any way to do it but without showing the stack trace (you don't want the final user to see it) and using throw.
Note: No, I don't want to catch the expression, I want to terminate the program after throwing the exception showing a message but without the stack trace.
Example:
class MyErrors implements Exception{
var notInt;
MyErrors(this.notInt);
}
void main(List<String> args) {
var myErrors = MyErrors("The input wasn't an int, please restart the program");
throw myErrors.notInt
}
Why not just have main()
be a giant try/catch, with the rest of your program called from try, and the catch block logging the error/stacktrace for smart people to review, and perhaps the finally block to restart the app?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.