Typescript Functional Error Handling