-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #409 from ably/fix/java-enum-serialization-exceptions
Replaced silent serialization errors with exceptions
- Loading branch information
Showing
2 changed files
with
34 additions
and
13 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
23 changes: 23 additions & 0 deletions
23
android/src/main/java/io/ably/flutter/plugin/types/SerializationException.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,23 @@ | ||
package io.ably.flutter.plugin.types; | ||
|
||
/** | ||
* Thrown during object serialization | ||
*/ | ||
public class SerializationException extends RuntimeException { | ||
|
||
public SerializationException(String message) { | ||
super(message); | ||
} | ||
|
||
public static SerializationException forEnum(Object value, Class type) { | ||
return new SerializationException(value.toString() + " can't be encoded/decoded to " + type.toString()); | ||
} | ||
|
||
public static SerializationException forEncoder(Class type) { | ||
return new SerializationException("No encoder found for " + type.toString()); | ||
} | ||
|
||
public static SerializationException forDecoder(Object value) { | ||
return new SerializationException("No decoder found for value " + value.toString()); | ||
} | ||
} |