AnyUnpackError.swift 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Sources/SwiftProtobuf/AnyUnpackError.swift - Any Unpacking 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. /// Errors that can be throw when unpacking a Google_Protobuf_Any.
  12. ///
  13. // -----------------------------------------------------------------------------
  14. /// Describes errors that can occur when unpacking an `Google_Protobuf_Any`
  15. /// message.
  16. ///
  17. /// `Google_Protobuf_Any` messages can be decoded from protobuf binary, text
  18. /// format, or JSON. The contents are not parsed immediately; the raw data is
  19. /// held in the `Google_Protobuf_Any` message until you `unpack()` it into a
  20. /// message. At this time, any error can occur that might have occurred from a
  21. /// regular decoding operation. There are also other errors that can occur due
  22. /// to problems with the `Any` value's structure.
  23. public enum AnyUnpackError: Error {
  24. /// The `type_url` field in the `Google_Protobuf_Any` message did not match
  25. /// the message type provided to the `unpack()` method.
  26. case typeMismatch
  27. /// Well-known types being decoded from JSON must have only two fields: the
  28. /// `@type` field and a `value` field containing the specialized JSON coding
  29. /// of the well-known type.
  30. case malformedWellKnownTypeJSON
  31. /// The `Google_Protobuf_Any` message was malformed in some other way not
  32. /// covered by the other error cases.
  33. case malformedAnyField
  34. }