InvalidJsonException class

Exception thrown when JSON data from Firestore is invalid or cannot be parsed

This exception provides detailed context about the invalid JSON data, including where it came from and what went wrong. It's useful for:

  • Debugging data conversion issues
  • Tracking down malformed documents
  • Validating data integrity
  • Error reporting and logging

Example:

try {
  final user = User.fromJson(json);
} catch (e) {
  throw InvalidJsonException(
    id: documentId,
    path: 'users',
    api: 'UserApi',
    data: json,
  );
}
Implemented types

Constructors

InvalidJsonException.new({required String id, required String path, required String api, required Map<String, dynamic> data})
Creates a new invalid JSON exception with context
const

Properties

api String
The name of the API that encountered the invalid JSON
final
data Map<String, dynamic>
The actual invalid JSON data that caused the error
final
hashCode int
The hash code for this object.
no setterinherited
id String
The document ID where the invalid JSON was found
final
path String
The Firestore path where the document exists
final
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.
override

Operators

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