Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

An ambigous exception on unknown type serialization #10

Closed
rothschild86 opened this issue Jul 1, 2013 · 3 comments
Closed

An ambigous exception on unknown type serialization #10

rothschild86 opened this issue Jul 1, 2013 · 3 comments

Comments

@rothschild86
Copy link

If there is a Java.util.date property on the entity, "Failed to instantiate model class - does it have a public null constructor?" exception is thrown.

In this case it happened because Entity.load() method swallowed IllegalArgumentExeption and replaced it with ORMDroidException.

catch (Exception e) {
throw new ORMDroidException(
"Failed to instantiate model class - does it have a public null constructor?",
e);
}

Perhaps ORMDroidException should at least print e.getClass() for the original exception?

But even then IllegalArgumentExeption does not quite indicate that there was a problem with type serialization. Needs better handling?

On the subject of dates, since util.Date, maybe it is worth serializing it (maybe not)? Azure Mobile Services handles it this way and it works quite well:

https://github.com/WindowsAzure/azure-mobile-services/blob/master/sdk/android/src/sdk/src/com/microsoft/windowsazure/mobileservices/DateSerializer.java

roscopeco added a commit that referenced this issue Jul 2, 2013
* Give more meaningful exceptions from Entity#load()
* Remove default type mapping (it doesn't work with the new load API)
* Add mapping for java.util.Date.

Thanks to rothschild86 for this bug report.
@roscopeco
Copy link
Owner

Fixed in master. Will make next release.

@roscopeco
Copy link
Owner

Thanks for the report!

This fix brings in a (minor) API change, in that it removes the default mapping. If your code relies on it you must now set the default mapping manually using TypeMapper#setDefaultMapping.

@rothschild86
Copy link
Author

DateMapper - sweet! :) Lot's of good changes man. Loving it!

On Mon, Jul 1, 2013 at 9:15 PM, Ross Bamford notifications@github.comwrote:

Thanks for the report!

This fix brings in a (minor) API change, in that it removes the default
mapping. If your code relies on it you must now set the default mapping
manually using TypeMapper#setDefaultMapping.


Reply to this email directly or view it on GitHubhttps://github.com//issues/10#issuecomment-20321048
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants