RequestError.fromJson constructor

RequestError.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json, {
  4. ClientUriConverter? clientUriConverter,
})

Implementation

factory RequestError.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  json ??= {};
  if (json is Map) {
    RequestErrorCode code;
    if (json.containsKey('code')) {
      code = RequestErrorCode.fromJson(
        jsonDecoder,
        '$jsonPath.code',
        json['code'],
        clientUriConverter: clientUriConverter,
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'code');
    }
    String message;
    if (json.containsKey('message')) {
      message = jsonDecoder.decodeString(
        '$jsonPath.message',
        json['message'],
      );
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'message');
    }
    String? stackTrace;
    if (json.containsKey('stackTrace')) {
      stackTrace = jsonDecoder.decodeString(
        '$jsonPath.stackTrace',
        json['stackTrace'],
      );
    }
    return RequestError(code, message, stackTrace: stackTrace);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'RequestError', json);
  }
}