Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle UnDeserializableValue in SnakDeserializer #21

Merged
merged 1 commit into from Jun 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Deserializers/SnakDeserializer.js
Expand Up @@ -35,7 +35,7 @@ MODULE.SnakDeserializer = util.inherit( 'WbSnakDeserializer', PARENT, {
try {
dataValue = dv.newDataValue( type, value );
} catch( error ) {
dataValue = new dv.UnDeserializableValue( value, type, error );
dataValue = new dv.UnDeserializableValue( value, type, error.message );
}

return new wb.datamodel.PropertyValueSnak( serialization.property, dataValue );
Expand Down
19 changes: 19 additions & 0 deletions tests/Deserializers/SnakDeserializer.tests.js
Expand Up @@ -31,6 +31,25 @@ var testSets = [
}
},
new wb.datamodel.PropertyValueSnak( 'P1', new dv.StringValue( 'some string' ) )
], [
{
snaktype: 'value',
property: 'P1',
datavalue: {
type: 'undeserializable',
value: {
value: { foo: 'bar' },
type: 'string',
error: 'String is invalid.'
}
}
},
new wb.datamodel.PropertyValueSnak( 'P1', new dv.UnDeserializableValue(
{ foo: 'bar' },
'string',
'String is invalid.'
)
)
]
];

Expand Down