question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Swallowing of errors

See original GitHub issue

Hi 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:closed
  • Created 5 years ago
  • Comments:47 (29 by maintainers)

github_iconTop GitHub Comments

1reaction
lostpebblecommented, Sep 28, 2020

Okay cool. Interested to hear what you have put together on the next walk 😃

1reaction
brilloutcommented, Sep 24, 2020

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found