xxxxxxxxxx
try {
// code that might throw an exception
}
on Exception1 {
// code for handling exception
}
catch Exception2 {
// code for handling exception
}
xxxxxxxxxx
try {
final db = await database;
await db.insert(
_tableName,
message,
conflictAlgorithm: ConflictAlgorithm.replace,
);
} catch (e) {
print('Failed to add message: $e');
}