DefaultErrorResponse.fromJson constructor

DefaultErrorResponse.fromJson(
  1. Map<String, dynamic> json
)

Factory constructor to create an instance from a JSON object.

Implementation

factory DefaultErrorResponse.fromJson(Map<String, dynamic> json) {
  if (!json.containsKey('status') ||
      !json.containsKey('error') ||
      !json.containsKey('message')) {
    throw ArgumentError('Missing required error response fields.');
  }

  return DefaultErrorResponse(
    status: json['status'] as int,
    error: json['error'] as String,
    message: json['message'] as String,
  );
}