libp2p / js-libp2p

The JavaScript Implementation of libp2p networking stack.
https://libp2p.io
Other
2.29k stars 438 forks source link

fix: add name property to exported interface errors #2446

Closed 2color closed 5 months ago

2color commented 5 months ago

Description

As discussed in https://github.com/ipfs/helia-verified-fetch/issues/25#issuecomment-2018003309, this PR adds the name property to the AbortError type.

This has a couple of benefits:

Notes & open questions

Change checklist

SgtPooki commented 5 months ago

https://github.com/nodejs/node/issues/40692#issuecomment-956658594 has some relevant discussions about custom AbortError's too. Also some deets in https://github.com/ipfs/helia-verified-fetch/issues/25#issuecomment-2018375288

achingbrain commented 5 months ago

Should we also set the name property on UnexpectedPeerError, InvalidCryptoExchangeError and InvalidCryptoTransmissionError?

Sorry, missed this - yes, I think we should.

2color commented 5 months ago

Should we also set the name property on UnexpectedPeerError, InvalidCryptoExchangeError and InvalidCryptoTransmissionError?

Sorry, missed this - yes, I think we should.

Ok I'll update the pr

achingbrain commented 5 months ago

Just noticed that DOMException officially doesn't have a .stack property, and technically neither does Error, though every JS runtime adds it - there's a tc39 proposal to add it that's been around for, oh, 8 years 🤦