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 151 views
151 views asked Oct 21, 2022 by avibootz
3 answers 238 views
238 views asked Mar 13, 2023 by avibootz
1 answer 177 views
177 views asked Oct 22, 2022 by avibootz
1 answer 124 views
124 views asked Oct 21, 2022 by avibootz
1 answer 125 views
1 answer 147 views
147 views asked Oct 12, 2022 by avibootz
...