How to print exception and StackTrace in Dart

1 Answer

0 votes
main() {
    try {
        throw "throw exception";
    } catch (e, s) {
        print("Exception: $e");
        print("StackTrace: $s");
    }
}




/*
run:

Exception: throw exception
StackTrace: #0      main (file:///home/jdoodle.dart:3:9)
#1      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:283:19)
#2      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

*/

 



answered Oct 22, 2022 by avibootz

Related questions

2 answers 277 views
277 views asked Oct 21, 2022 by avibootz
3 answers 408 views
408 views asked Mar 13, 2023 by avibootz
1 answer 271 views
271 views asked Oct 22, 2022 by avibootz
1 answer 218 views
218 views asked Oct 21, 2022 by avibootz
1 answer 218 views
1 answer 250 views
250 views asked Oct 12, 2022 by avibootz
...