Closed pickworth closed 8 years ago
What's the expected behaviour? Can you provide a small replication to demonstrate the issue?
The RAML document, I assume, defines that you need a body and the application has not sent a body with the HTTP request.
it's okay, i guess i can use something like:
if(err.name == "UnsupportedMediaTypeError" )){
res.status(415);
....
}
I was just expecting err.code to have 415 in it, instead it is undefined err.type is undefined also
Probably this isn't a real a bug, sorry
@nmors Now I understand, cheers! It is created with 415
, it has a status
property which means default Express.js error handlers will use the correct HTTP status code: https://github.com/mulesoft-labs/osprey-method-handler/blob/master/osprey-method-handler.js#L306.
Let me know if the status
property helps you, it's the "standard" way in Express.js to communicate the HTTP status code (E.g. https://github.com/jshttp/http-errors/blob/master/index.js#L97).
yep! checking error.status now for handling my errors. thanks for your help
No problem, closing it resolved :+1: It sounds like you may have been trying to do something else, just keep in mind other middleware can respond with a status error of 415
too (since it's just a HTTP code).
Hi @nmors I've the same problem. How did you solve? pls
UnsupportedMediaTypeError: No body sent with request for PUT /api/something with content-type "undefined"
Seems that there is no way to handle such error ?
err object appears to be empty for this case.
Please advise
Thanks