Skip to content

Commit

Permalink
Roll back other enum-related breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gjcairo committed Apr 5, 2024
1 parent 33cf83a commit 6b961bd
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 30 deletions.
4 changes: 0 additions & 4 deletions Sources/SwiftProtobuf/BinaryDecodingError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,4 @@ public enum BinaryDecodingError: Error {

/// Reached the nesting limit for messages within messages while decoding.
case messageDepthLimit

/// Bytes and Strings have a max size of 2GB. And since messages are on the
/// wire as bytes/length delimited, they also have a 2GB size limit.
case tooLarge
}
17 changes: 0 additions & 17 deletions Sources/SwiftProtobuf/BinaryDelimited.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,6 @@ public enum BinaryDelimited {
/// While reading/writing to the stream, less than the expected bytes was
/// read/written.
case truncated

/// Messages are limited by the protobuf spec to 2GB; when decoding, if the
/// length says the payload is over 2GB, this error is raised.
case tooLarge

/// While attempting to read the length of a message on the stream, the
/// bytes were malformed for the protobuf format.
case malformedLength

/// This isn't really an "error". `InputStream` documents that
/// `hasBytesAvailable` _may_ return `True` if a read is needed to
/// determine if there really are bytes available. So this "error" is throw
/// when a `parse` or `merge` fails because there were no bytes available.
/// If this is rasied, the callers should decides via what ever other means
/// are correct if the stream has completely ended or if more bytes might
/// eventually show up.
case noBytesAvailable
}

#if !os(WASI)
Expand Down
8 changes: 1 addition & 7 deletions Sources/SwiftProtobuf/BinaryEncodingError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,12 @@

/// Describes errors that can occur when decoding a message from binary format.
@available(*, deprecated, message: "This error type has been deprecated and won't be thrown anymore; it has been replaced by `SwiftProtobufError`.")
public enum BinaryEncodingError: Error, Equatable {
/// `Any` fields that were decoded from JSON cannot be re-encoded to binary
/// unless the object they hold is a well-known type or a type registered via
/// `Google_Protobuf_Any.register()`.
case anyTypeURLNotRegistered(typeURL: String)
public enum BinaryEncodingError: Error, Hashable {
/// An unexpected failure when deserializing a `Google_Protobuf_Any`.
case anyTranscodeFailure
/// The definition of the message or one of its nested messages has required
/// fields but the message being encoded did not include values for them. You
/// must pass `partial: true` during encoding if you wish to explicitly ignore
/// missing required fields.
case missingRequiredFields
/// Messages are limited to a maximum of 2GB in encoded size.
case tooLarge
}
4 changes: 2 additions & 2 deletions Sources/SwiftProtobuf/JSONEncodingError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
// -----------------------------------------------------------------------------

@available(*, deprecated, message: "This error type has been deprecated and won't be thrown anymore; it has been replaced by `SwiftProtobufError`.")
public enum JSONEncodingError: Error, Equatable {
public enum JSONEncodingError: Error, Hashable {
/// Any fields that were decoded from binary format cannot be
/// re-encoded into JSON unless the object they hold is a
/// well-known type or a type registered with via
/// Google_Protobuf_Any.register()
case anyTypeURLNotRegistered(typeURL: String)
case anyTranscodeFailure
/// Timestamp values can only be JSON encoded if they hold a value
/// between 0001-01-01Z00:00:00 and 9999-12-31Z23:59:59.
case timestampRange
Expand Down

0 comments on commit 6b961bd

Please sign in to comment.