JSONDecodingError.swift 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Sources/SwiftProtobuf/JSONDecodingError.swift - JSON decoding errors
  2. //
  3. // Copyright (c) 2014 - 2017 Apple Inc. and the project authors
  4. // Licensed under Apache License v2.0 with Runtime Library Exception
  5. //
  6. // See LICENSE.txt for license information:
  7. // https://github.com/apple/swift-protobuf/blob/main/LICENSE.txt
  8. //
  9. // -----------------------------------------------------------------------------
  10. ///
  11. /// JSON decoding errors
  12. ///
  13. // -----------------------------------------------------------------------------
  14. public enum JSONDecodingError: Error {
  15. /// Something was wrong
  16. case failure
  17. /// A number could not be parsed
  18. case malformedNumber
  19. /// Numeric value was out of range or was not an integer value when expected
  20. case numberRange
  21. /// A map could not be parsed
  22. case malformedMap
  23. /// A bool could not be parsed
  24. case malformedBool
  25. /// We expected a quoted string, or a quoted string has a malformed backslash sequence
  26. case malformedString
  27. /// We encountered malformed UTF8
  28. case invalidUTF8
  29. /// The message does not have fieldName information
  30. case missingFieldNames
  31. /// The data type does not match the schema description
  32. case schemaMismatch
  33. /// A value (text or numeric) for an enum was not found on the enum
  34. case unrecognizedEnumValue
  35. /// A 'null' token appeared in an illegal location.
  36. /// For example, Protobuf JSON does not allow 'null' tokens to appear
  37. /// in lists.
  38. case illegalNull
  39. /// A map key was not quoted
  40. case unquotedMapKey
  41. /// JSON RFC 7519 does not allow numbers to have extra leading zeros
  42. case leadingZero
  43. /// We hit the end of the JSON string and expected something more...
  44. case truncated
  45. /// A JSON Duration could not be parsed
  46. case malformedDuration
  47. /// A JSON Timestamp could not be parsed
  48. case malformedTimestamp
  49. /// A FieldMask could not be parsed
  50. case malformedFieldMask
  51. /// Extraneous data remained after decoding should have been complete
  52. case trailingGarbage
  53. /// More than one value was specified for the same oneof field
  54. case conflictingOneOf
  55. /// Reached the nesting limit for messages within messages while decoding.
  56. case messageDepthLimit
  57. /// Encountered an unknown field with the given name. When parsing JSON, you
  58. /// can instead instruct the library to ignore this via
  59. /// JSONDecodingOptions.ignoreUnknownFields.
  60. case unknownField(String)
  61. }