-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor protobuf validation exceptions.
- Loading branch information
1 parent
570b4d7
commit 0762a93
Showing
5 changed files
with
98 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
.../src/main/java/org/whispersystems/signalservice/api/InvalidMessageStructureException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.whispersystems.signalservice.api; | ||
|
||
import org.whispersystems.libsignal.util.guava.Optional; | ||
|
||
/** | ||
* An exception thrown when something about the proto is malformed. e.g. one of the fields has an invalid value. | ||
*/ | ||
public final class InvalidMessageStructureException extends Exception { | ||
|
||
private final Optional<String> sender; | ||
private final Optional<Integer> device; | ||
|
||
public InvalidMessageStructureException(String message) { | ||
super(message); | ||
this.sender = Optional.absent(); | ||
this.device = Optional.absent(); | ||
} | ||
|
||
public InvalidMessageStructureException(String message, String sender, int device) { | ||
super(message); | ||
this.sender = Optional.fromNullable(sender); | ||
this.device = Optional.of(device); | ||
} | ||
|
||
public InvalidMessageStructureException(Exception e, String sender, int device) { | ||
super(e); | ||
this.sender = Optional.fromNullable(sender); | ||
this.device = Optional.of(device); | ||
} | ||
|
||
public InvalidMessageStructureException(Exception e) { | ||
super(e); | ||
this.sender = Optional.absent(); | ||
this.device = Optional.absent(); | ||
} | ||
|
||
public Optional<String> getSender() { | ||
return sender; | ||
} | ||
|
||
public Optional<Integer> getDevice() { | ||
return device; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.