Comments (3)
e => e instanceof Error ? e : new Error(e)
Maybe we could use Error.cause
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause
from fp-ts-std.
e => e instanceof Error ? e : new Error(e)
Maybe we could use
Error.cause
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause
That looks nice:
> Error('bar', { cause: Error('foo') })
Error: bar
at REPL5:1:1
at Script.runInThisContext (node:vm:129:12)
... 7 lines matching cause stack trace ...
at [_line] [as _line] (node:internal/readline/interface:893:18) {
[cause]: Error: foo
at REPL5:1:23
at Script.runInThisContext (node:vm:129:12)
at REPLServer.defaultEval (node:repl:572:29)
at bound (node:domain:433:15)
at REPLServer.runBound [as eval] (node:domain:444:12)
at REPLServer.onLine (node:repl:902:10)
at REPLServer.emit (node:events:525:35)
at REPLServer.emit (node:domain:489:12)
at [_onLine] [as _onLine] (node:internal/readline/interface:422:12)
at [_line] [as _line] (node:internal/readline/interface:893:18)
}
The only thing that gives me pause is that if a consumer is using their own error classes extending Error
they'll lose the ability to check instanceof
directly on the thrown error, which may be surprising:
> class Error2 extends Error {}
> e2 = new Error2()
> ee = new Error('', { cause: e2 })
> e2 instanceof Error2
true
> ee instanceof Error2
false
from fp-ts-std.
from fp-ts-std.
Related Issues (20)
- IOOption type HOT 1
- Use NonEmptyString in Env HOT 1
- isInstanceOf constructor - constrain return type? HOT 1
- Enum typeclasses HOT 2
- More tuple operators HOT 1
- fp-ts backports HOT 2
- get for struct
- Monadic memptyWhen/Unless HOT 1
- Do & apS HOT 1
- `pass` HOT 1
- `Struct.getEnum`
- `pass` doesn't widen additional type arguments HOT 1
- Real ESM support HOT 9
- process module
- Many URLPath functions should exist in URL too HOT 1
- `N.fromString()` should not use `Number.parseInt()` HOT 2
- Unable to import fp-ts-std HOT 6
- URLPath origin/base can be lost HOT 1
- As compared to Ramda: equals - checkmark should probably be unchecked HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fp-ts-std.