Swallowing of errors
See original GitHub issueHi there,
Loving the simplicity of this library. I’ve just got a couple issues I’d like some clarification on.
How do I catch errors that occur inside my async function for my endpoint.
For example:
import { endpoints } from "wildcard-api";
endpoints.runThing = async function({ argument }) {
doSomethingWithArgument(argument); <-- This throws an Error
};
These errors are being swallowed and handled by Wildcard API, and the only result I get back from my request is:
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
Content-Length: 51
Date: Tue, 05 Mar 2019 14:29:25 GMT
Connection: keep-alive
{"usageError":"Endpoint could not handle request."}
Response code: 400 (Bad Request); Time: 49ms; Content length: 51 bytes
I would like to wrap my entire API in my own error handling, as I return certain structures of JSON from all my API endpoints for my client to handle as it likes. This includes uncaught errors in my API code - as of now I have no way to intercept that error and return my own structured response.
Issue Analytics
- State:
- Created 5 years ago
- Comments:47 (29 by maintainers)
Top Results From Across the Web
How to prevent promises swallowing errors ? - GeeksforGeeks
In this article, we will try to understand how we may prevent the promises swallowing errors using several predefined techniques provided by ...
Read more >Are JavaScript Promises swallowing your errors?
Promises swallows errors by default ! Who's idea was that? More specifically, any exception which is thrown within a then handler, a catch ......
Read more >swallowing-errors.js - gists · GitHub
const body = await client.get('http://example.com/users');. const users = body.users || [];. // do something with users. } catch (err) {. // handle error....
Read more >Do not swallow exceptions - Semicolon & Sons
I had failing tests for a bulk email operation, but nothing seemed to appear in the logs and no exceptions were thrown. After...
Read more >Why You Should Not Swallow Errors | by Teri Radichel - Medium
ACM.113 Example demonstrating how swallowing errors can come back to bite. This is a continuation of my series of posts on Automating ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay cool. Interested to hear what you have put together on the next walk 😃
There is a legacy reason why Wildcard formats its own errors but I don’t think it’s required anymore, I’ll reevaluate this. And you’re right I should and I will reduce chars and
console
calls to a minimum. Thanks!