resolveError method

  1. @override
Object resolveError(
  1. Object error,
  2. StackTrace stackTrace,
  3. Object? operation,
  4. Object? previousError,
)
override

Implementation

@override
Object resolveError(Object error, StackTrace stackTrace, Object? operation,
    Object? previousError) {
  if (error is DBPostgreSQLAdapterException) {
    return error;
  } else if (error is PostgreSQLException) {
    if (error.severity == PostgreSQLSeverity.error) {
      if (error.code == '23505') {
        return EntityFieldInvalid("unique", error.detail,
            fieldName: error.columnName,
            tableName: error.tableName,
            parentError: error,
            previousError: previousError,
            operation: operation);
      } else if (error.code == '23503') {
        return DBPostgreSQLAdapterException("delete.constraint",
            '${error.message} ; Detail: ${error.detail} ; Table: ${error.tableName} ; Constraint: ${error.constraintName}',
            parentError: error,
            parentStackTrace: stackTrace,
            previousError: previousError,
            operation: operation);
      }
    }
  }

  return DBPostgreSQLAdapterException('error', '$error',
      parentError: error,
      parentStackTrace: stackTrace,
      previousError: previousError,
      operation: operation);
}