B
B
beduin012020-12-25 11:08:20
Dart
beduin01, 2020-12-25 11:08:20

Why is the exception not being caught?

There is the following Dart code:

try 
{
  print("!1111111111");
  await db.KVToTableInsert(tableToInsert);
  print("!2222222222");
  return dbEnums.success;
} on PostgreSQLException 
{
    print("Fail is here");
}


It crashes in the console:
!1111111111
Unhandled exception:
PostgreSQLSeverity.unknown 23505


Tried catching:
on Exception {print("Base Exception");}

Current implementation of the insert method:
KVToTableInsert(String tablename, Map jsonMap) async {
    // print(jsonMap);
    List insertNoticeKeys = [];
    List insertNoticeValues = [];
    jsonMap.forEach((key, value) async {
      if (value is List) // nested
      {
        value.forEach((item) async {
        await KVToTableInsert(key, item);
        });
      } else {


Everything seems to be correct with async/await?

Everything looks like this: https://images.guru/i/dBWpe

But it didn't help either. What could be the reason?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2020-12-25
@vabka

try instead on Exception-catch(e)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question