Index: third_party/protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java |
diff --git a/third_party/protobuf/java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java |
similarity index 92% |
rename from third_party/protobuf/java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java |
rename to third_party/protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java |
index 0a76105278fba5d2a2127117c99e36846017d659..85ce7b24ac8a116f876a0cd274368b40219c2a3a 100644 |
--- a/third_party/protobuf/java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java |
+++ b/third_party/protobuf/java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java |
@@ -46,6 +46,10 @@ public class InvalidProtocolBufferException extends IOException { |
super(description); |
} |
+ public InvalidProtocolBufferException(IOException e) { |
+ super(e.getMessage(), e); |
+ } |
+ |
/** |
* Attaches an unfinished message to the exception to support best-effort |
* parsing in {@code Parser} interface. |
@@ -66,6 +70,14 @@ public class InvalidProtocolBufferException extends IOException { |
return unfinishedMessage; |
} |
+ /** |
+ * Unwraps the underlying {@link IOException} if this exception was caused by an I/O |
+ * problem. Otherwise, returns {@code this}. |
+ */ |
+ public IOException unwrapIOException() { |
+ return getCause() instanceof IOException ? (IOException) getCause() : this; |
+ } |
+ |
static InvalidProtocolBufferException truncatedMessage() { |
return new InvalidProtocolBufferException( |
"While parsing a protocol message, the input ended unexpectedly " + |