Reputation: 351
I just started working on an API, which is a NodeJS app, which uses Hapi, which in turn uses Boom. Boom is great, but it hides from me some errors that I would like to see.
Working locally on my Mac, I open 2 terminal windows. In one terminal I run "npm start" which gets the API running locally. In the other terminal, I test the API with this cURL call:
curl 'http://needi.local:8080/search/uber' -X GET --header 'Accept: application/json' --header 'x-api-key: 2gt7Pt2LU194KKcNnc'
And that works great! I get all the data I expect.
So now I put this inside of a bash script:
#!/usr/bin/ sh
curl 'http://needi.local:8080/search/uber' -X GET --header 'Accept: application/json' --header 'x-api-key: 2gt7Pt2LU194KKcNnc'
Now I run this and instead of getting the data, I get this:
% Total % Received % Xferd Average Speed Time Time
Time Current
Dload Upload Total Spent
Left Speed
100 109 100 109 0 0 3858 0 --:--:-- --:--:--
--:--:-- 3892
{
"statusCode": 500,
"error": "Internal Server Error",
"message": "An internal server error occurred"
}
This message appears to be generated from Boom. When I grep the code I only see this message coming from Boom. The message is described here:
https://github.com/hapijs/boom
That's all good, up to a point. Given a problem, Boom should send back that message. That's fine.
But whatever the problem is, it never shows up in the other terminal window, where I am running the app. I expect a stacktrace to show up, but it doesn't.
So perhaps Boom swallows the error? How can I get the error to appear in the log (the terminal that is running the API).
Or perhaps Boom is innocent. Perhaps this is simply a case of an Exception that is not being caught?
Upvotes: 2
Views: 1767
Reputation: 124
You might want to have a look at the way boom is implemented in your JavaScript files.
According to the official boom documentation:
All 500 errors hide your message from the end user.
Furthermore, the docs explain what happens if no status code is set in a boom object:
Defaults to 500 if no status code is already set.
This defaulting to a 500 error code is a security measure to prevent the actual error from being exposed to clients.
Upvotes: 1