ServerErrorParams.fromJson constructor

ServerErrorParams.fromJson(
  1. JsonDecoder jsonDecoder,
  2. String jsonPath,
  3. Object? json
)

Implementation

factory ServerErrorParams.fromJson(
    JsonDecoder jsonDecoder, String jsonPath, Object? json) {
  json ??= {};
  if (json is Map) {
    bool isFatal;
    if (json.containsKey('isFatal')) {
      isFatal = jsonDecoder.decodeBool('$jsonPath.isFatal', json['isFatal']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'isFatal');
    }
    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']);
    } else {
      throw jsonDecoder.mismatch(jsonPath, 'stackTrace');
    }
    return ServerErrorParams(isFatal, message, stackTrace);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'server.error params', json);
  }
}