PluginErrorParams.fromJson constructor

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

Implementation

factory PluginErrorParams.fromJson(
  JsonDecoder jsonDecoder,
  String jsonPath,
  Object? json, {
  ClientUriConverter? clientUriConverter,
}) {
  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 PluginErrorParams(isFatal, message, stackTrace);
  } else {
    throw jsonDecoder.mismatch(jsonPath, 'plugin.error params', json);
  }
}