# Exception InvalidProtocolBufferException (3.19.4)

    public class InvalidProtocolBufferException extends IOException

Thrown when a protocol message being parsed is invalid in some way, e.g. it contains a malformed
varint or a negative byte length.

## Inherited Members

[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) [Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) [Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) [Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) [Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) [Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) [Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) [Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) [Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) [Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-) [Throwable.addSuppressed(Throwable)](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#addSuppressed-java.lang.Throwable-) [Throwable.fillInStackTrace()](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#fillInStackTrace--) [Throwable.getCause()](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#getCause--) [Throwable.getLocalizedMessage()](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#getLocalizedMessage--) [Throwable.getMessage()](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#getMessage--) [Throwable.getStackTrace()](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#getStackTrace--) [Throwable.getSuppressed()](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#getSuppressed--) [Throwable.initCause(Throwable)](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#initCause-java.lang.Throwable-) [Throwable.printStackTrace()](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#printStackTrace--) [Throwable.printStackTrace(PrintStream)](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#printStackTrace-java.io.PrintStream-) [Throwable.printStackTrace(PrintWriter)](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#printStackTrace-java.io.PrintWriter-) [Throwable.setStackTrace(StackTraceElement\[\])](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#setStackTrace-java.lang.StackTraceElement[]-) [Throwable.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#toString--)

## Constructors

### InvalidProtocolBufferException(IOException e)

    public InvalidProtocolBufferException(IOException e)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `e` | `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |

### InvalidProtocolBufferException(String description)

    public InvalidProtocolBufferException(String description)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `description` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |

### InvalidProtocolBufferException(String description, IOException e)

    public InvalidProtocolBufferException(String description, IOException e)

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `description` | `https://docs.oracle.com/javase/8/docs/api/java/lang/String.html` |
| `e` | `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |

## Methods

### getUnfinishedMessage()

    public MessageLite getUnfinishedMessage()

Returns the unfinished message attached to the exception, or null if no message is attached.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite` |   |

### setUnfinishedMessage(MessageLite unfinishedMessage)

    public InvalidProtocolBufferException setUnfinishedMessage(MessageLite unfinishedMessage)

Attaches an unfinished message to the exception to support best-effort parsing in `
Parser` interface.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `unfinishedMessage` | `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.MessageLite` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/java/docs/reference/protobuf/latest/com.google.protobuf.InvalidProtocolBufferException` | this |

### unwrapIOException()

    public IOException unwrapIOException()

Unwraps the underlying [IOException](https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html) if this exception was caused by an I/O problem.
Otherwise, returns `this`.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html` |   |