BinaryDecodingError.swift 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Sources/SwiftProtobuf/BinaryDecodingError.swift - Protobuf binary 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. /// Protobuf binary format decoding errors
  12. ///
  13. // -----------------------------------------------------------------------------
  14. /// Describes errors that can occur when decoding a message from binary format.
  15. public enum BinaryDecodingError: Error {
  16. /// Extraneous data remained after decoding should have been complete.
  17. case trailingGarbage
  18. /// The decoder unexpectedly reached the end of the data before it was
  19. /// expected.
  20. case truncated
  21. /// A string field was not encoded as valid UTF-8.
  22. case invalidUTF8
  23. /// The binary data was malformed in some way, such as an invalid wire format
  24. /// or field tag.
  25. case malformedProtobuf
  26. /// The definition of the message or one of its nested messages has required
  27. /// fields but the binary data did not include values for them. You must pass
  28. /// `partial: true` during decoding if you wish to explicitly ignore missing
  29. /// required fields.
  30. case missingRequiredFields
  31. /// An internal error happened while decoding. If this is ever encountered,
  32. /// please file an issue with SwiftProtobuf with as much details as possible
  33. /// for what happened (proto definitions, bytes being decoded (if possible)).
  34. case internalExtensionError
  35. /// Reached the nesting limit for messages within messages while decoding.
  36. case messageDepthLimit
  37. }