Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add structured errors to Typescript Client (encoredev#224)
This commit adds structured errors to the typescript client in the form of an `EncoreError` object which will be thrown incase of an error. This makes a best attempt at recovering the structured error as reported by an Encore API and parsing it to be easily usable from withing a client. This also causes the client to premptively return throw an error if no bearer token is present when trying to call an Authenticated API. Fixes encoredev#114 ```typescript const client = new Client(Local) try { const productListing = await client.products.List() } catch (e: Error) { if (isEncoreError(e)) { console.log(`Got an ${e.code} error with message ${e.message} and details ${e.details}`) } else { console.log(`Got error ${e.message}`) } } ```
- Loading branch information