10. T H RO W E R RO R S
• Caller must handle it by try-catch
• Break the flow of caller
• Less expressive
• Deceive Function Signature
• Try-catch usually for interaction with external systems
11. G O A L S
• Honest and expressive signature
• Support a number of error types for caller
• Solid way to identify error types
• Don’t break the flow
12. G O L A N G WAY
• Encapsulate the result to an array
• Return the array
Reference: https://dev.to/oieduardorabelo/javascript-handling-errors-like-go-3efk
16. F U N C T I O N A L P R O G R A M M I N G
• Functions are first-class citizens
• Expression > Statement
• Pure Function with no side effects
17. M O N A D
• A monad is a way of composing functions that require
context in addition to the return value, such as
computation, branching, or I/O.
• It is based on a simple symmetry — A way to wrap a
value into a context, and a way to unwrap the value
from the context
29. R E S O U R C E S
• JavaScript Monads Made Simple
• Type-Safe Error Handling In TypeScript
• Functional Error Handling with Express.js and DDD |
Enterprise Node.js + TypeScript
• Expressive error handling in TypeScript and benefits for
domain-driven design (medium star alert)
• Chapter 9: Monadic Onions