MongoErrorResponse class

Utility class for parsing and processing MongoDB error responses.

This class provides static methods to analyze MongoDB operation errors and convert them into a more accessible format. It's particularly useful for handling write errors that occur during insert, update, or delete operations.

The class can extract field-specific errors from MongoDB's error response format, making it easier to provide meaningful error messages to users and identify which fields caused validation or constraint violations.

Example:

// After a failed MongoDB operation
var errors = MongoErrorResponse.discoverError(result.serverResponses);
if (errors.containsKey('email')) {
  print('Email errors: ${errors['email']}');
}

Constructors

MongoErrorResponse.new()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

discoverError(List<Map<String, Object?>> response) Map<String, List<String>>
Analyzes MongoDB error responses and extracts field-specific errors.