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) {
    throw jsonDecoder.mismatch(jsonPath, "'RequestError'", json);
  }
  RequestErrorCode code;
  if (json case {'code': var encodedCode}) {
    code = RequestErrorCode.fromJson(
      jsonDecoder,
      '$jsonPath.code',
      encodedCode,
      clientUriConverter: clientUriConverter,
    );
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'code'", json);
  }
  String message;
  if (json case {'message': var encodedMessage}) {
    message = jsonDecoder.decodeString('$jsonPath.message', encodedMessage);
  } else {
    throw jsonDecoder.mismatch(jsonPath, "'message'", json);
  }
  String? stackTrace;
  if (json case {'stackTrace': var encodedStackTrace}) {
    stackTrace = jsonDecoder.decodeString(
      '$jsonPath.stackTrace',
      encodedStackTrace,
    );
  }
  return RequestError(code, message, stackTrace: stackTrace);
}