Replies: 1 comment
-
I think this betrays the "principle of least surprise". If I throw a string, it's because I want whoever catches it to receive a string.
An interesting pattern, indeed! Though it feels like you're reimplementing try-catch behavior in a sense (catch then rethrow) when using pass-through checks in
That sounds interesting. Have a few hypothetical examples to look at? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
PR #131 attemps to
tryitfunctiontryitfunction around without immediately destructing it.Improve typings
errorvariable in the below example asError | undefinedwhile the real type isstringThe new implementation will transform the string into a true
Errorobject.It is supposed to be "bad smell" to throw anything else than an Error object, this provides a safety net.
15, while it will printDivision by zeroif the first line of thetest()function is changed intoconst either = add(10, divide(20, 4))Allows to implement a error-handling pipe function
A
pipefunction can be built (in a next PR) that enhances thechainfunction with functional error handling i.e. a function that stops executing as soon as one function in the chain return an error - and returns that error.Beta Was this translation helpful? Give feedback.
All reactions