JsonException constructor Null safety

JsonException(
  1. JsonError error,
  2. {String? userReason}
)

Implementation

JsonException(this.error, {String? userReason}) {
  if (error == JsonError.unsupportedType) {
    reason = userReason ?? 'JSON Error: not a valid JSON value';
  } else if (error == JsonError.indexOutOfBounds) {
    reason = userReason ?? 'JSON Error: index out of bounds';
  } else if (error == JsonError.wrongType) {
    reason = userReason ?? 'JSON Error: either key is not a index type or value is not indexable';
  } else if (error == JsonError.notExist) {
    reason = userReason ?? 'JSON Error: key does\'t not exists';
  }
}