DEV Community

Discussion on: Library for Http errors in Typescript

Collapse
 
kop7 profile image
mkop • Edited

Yes, it's pretty similar :)

What do you think about my package, do you think its easier to use?

Collapse
 
evert profile image
Evert Pot

I think they are so close, that they're probably similar in terms of how easy they are to use.

I needed a few things that your package does not have though, maybe it's interesting.

  1. I needed the 'Http error' to exist as a type, so existing exceptions can expose their 'http status' without extending a class (which is not always possible)
  2. Some HTTP errors have additional information, like Retry-After and Allow headers, so I added those too.
  3. I added another type that can expose more information about the error, and directly maps to the application/problem+json type.

These together allowed me to make a good error-handling middleware:

github.com/curveball/problem/

So if you're looking for ideas, maybe that helps!