wrapAnyException method

SqfliteFfiException wrapAnyException(
  1. dynamic e
)

Wrap the exception, keeping sql/sqlArguments in error

Implementation

SqfliteFfiException wrapAnyException(dynamic e) {
  if (e is SqfliteFfiException) {
    e.database ??= getDatabase();
    e.sql ??= getSql();
    e.sqlArguments ??= getSqlArguments();
    if (e.database != null || e.sql != null || e.sqlArguments != null) {
      e.details ??= <String, Object?>{
        if (e.database != null) 'database': e.database!.toDebugMap(),
        if (e.sql != null) 'sql': e.sql,
        if (e.sqlArguments != null) 'arguments': e.sqlArguments
      };
    }
    return e;
  } else if (e is ffi.SqliteException) {
    return wrapAnyException(wrapSqlException(e));
  } else {
    return wrapAnyException(
        SqfliteFfiException(code: anyErrorCode, message: e.toString()));
  }
}