I've got a really simple example here. In this case, 'token' is a read-only property on the model, and throws an error when you try to write it. This is just present to force an error to show how .catch(...) isn't ever being called. The very simple example code is below (name, description, uptime are all variables set to static values before we get to this code):
models.TANServer.create({
name : name,
description : description,
defaultUpTime : defaultUpTime,
token : "apple"
})
.then( function( server ){
if( !server ){
res.statusCode = 400;
res.end( "unknown error creating new server entry" );
return;
}
res.statusCode = 200;
res.end( JSON.stringify( server ) );
return;
}).catch( function( reason ){
res.statusCode = 500;
res.end( "This should print out " + reason + " but is never called as the error stack goes to console, and nothing ever is caught." );
return;
});
The catch is never called, the http request just sits there spinning, and the console output pretty clearly displays that the exception just bubbled up without being caught.
What am I missing about .catch(...) in Sequelize calls?
Thanks.
The pertinent info from the exception stack output follows. The text "This is a read only property" is the error message I generate and toss when you try to write to that property.
Unhandled rejection Error: This is a read-only property
via ChrisH
No comments:
Post a Comment