tensorzero icon indicating copy to clipboard operation
tensorzero copied to clipboard

Expose gateway errors in TS client

Open chaance opened this issue 8 months ago • 0 comments

This PR refactors error handling in the TS client so that response errors more closely mirror those returned from the gateway. Errors that are properly handled can then be exposed directly to users with less obfuscation.

Closes https://github.com/tensorzero/tensorzero/issues/2168 and https://github.com/tensorzero/tensorzero/issues/1763


[!IMPORTANT] Refactor TS client error handling to use TensorZeroServerError for clearer gateway error messages.

  • Error Handling:
    • Introduces TensorZeroServerError in errors.ts to handle server errors with specific status codes and messages.
    • Replaces HttpError with TensorZeroServerError in tensorzero.ts for more detailed error handling.
    • Updates error handling in inference.ts, route.tsx, and tensorzero.server.ts to use isTensorZeroServerError() for checking server errors.
  • Code Refactoring:
    • Moves tensorzero.ts to tensorzero/tensorzero.ts and updates imports accordingly.
    • Removes ServerRequestError and isServerRequestError() from common.ts.
  • Dependencies:
    • Adds http-status-codes to package.json for standardized HTTP status codes.

This description was created by Ellipsis for 735445589c7a9fae54d4bf9ffddffb0bf23d92f8. You can customize this summary. It will automatically update as commits are pushed.

chaance avatar Jun 16 '25 16:06 chaance