mirror of https://github.com/Hax-io/jstruct
Exceptions
- Added `DeserializationError` Deserializer - On error now throws `DeserializationError` exception
This commit is contained in:
parent
2f4570d0fa
commit
dad7e04ccf
|
@ -4,7 +4,7 @@
|
|||
module jstruct.deserializer;
|
||||
|
||||
import std.json;
|
||||
import jstruct.exceptions : SerializationError;
|
||||
import jstruct.exceptions : DeserializationError;
|
||||
import std.traits : FieldTypeTuple, FieldNameTuple, isArray;
|
||||
|
||||
/**
|
||||
|
@ -191,8 +191,7 @@ public RecordType fromJSON(RecordType)(JSONValue jsonIn)
|
|||
}
|
||||
catch(JSONException e)
|
||||
{
|
||||
// TOOD: Should be DEserialization error
|
||||
throw new SerializationError();
|
||||
throw new DeserializationError();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +286,7 @@ unittest
|
|||
Person person = fromJSON!(Person)(json);
|
||||
assert(false);
|
||||
}
|
||||
catch(SerializationError)
|
||||
catch(DeserializationError)
|
||||
{
|
||||
assert(true);
|
||||
}
|
||||
|
|
|
@ -15,3 +15,11 @@ public final class SerializationError : JStructException
|
|||
super("Error serializing");
|
||||
}
|
||||
}
|
||||
|
||||
public final class DeserializationError : JStructException
|
||||
{
|
||||
this()
|
||||
{
|
||||
super("Error deserializing");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue