0

I have been getting very frustrated with Dart as runtime exceptions seem to fail silently. Program execution will continue after some type of failure and leave me totally stumped about what is not working and why. For example, in using aqueduct for dart server (this is not an issue unique to aqueduct, but dart in general) I have this code:

jsonData.forEach((jsonObject) async {
    ManagedObject record = Document();
    record.read(jsonObject);
    print(Util.jsonFormatToString(record.asMap()));
    ....more code
}

In this case, the application fails silently on record.read() falls out of the forEach loop and then continues code execution. During debugging, the application returns completely strange results and after debugging, presumably there is a problem with the jsonObject attempting to be read into the managed object, but Dart gives no notice that there is a problem or what that problem might be.

This is one example of many I have been running into.

Why does Dart fail so silently or am I missing some setting somewhere that is hiding critical info? I am using IntelliJ IDE.

jamesdlin
  • 81,374
  • 13
  • 159
  • 204
Jared Green
  • 196
  • 1
  • 7
  • If it's a problem with Dart in general, could you provide a reproducible example? – jamesdlin Jun 19 '20 at 17:54
  • I don't currently have any examples out of the context of the app I am building in flutter and with aqueduct. It's been a recurring issue in flutter and aqueduct - so I assume its Dart. What is strange is that I can wrap "record.read()" in a try/catch block and it will catch the exception, if I leave out the try/catch it fails silently. – Jared Green Jun 19 '20 at 18:20
  • 1
    I see you're running an asynchronous callback. Uncaught exceptions from asynchronous calls are handled differently (from the nearest error `Zone`). There are a number of cases where *Flutter* internally catches some exceptions (usually to show you a red screen of death instead of letting your application just exit); usually when this happens a diagnostic will be printed to the console or device log. – jamesdlin Jun 19 '20 at 18:31

0 Answers0