Skip to content

Comments

Update errors.ts#252

Open
Angel1945uwu wants to merge 1 commit intoPolymarket:mainfrom
Angel1945uwu:feat/typed-api-errors
Open

Update errors.ts#252
Angel1945uwu wants to merge 1 commit intoPolymarket:mainfrom
Angel1945uwu:feat/typed-api-errors

Conversation

@Angel1945uwu
Copy link

@Angel1945uwu Angel1945uwu commented Jan 6, 2026

Introduces a typed error model for CLOB API responses, making error handling more explicit and developer-friendly by mapping backend error codes to a dedicated ClobApiError class.


Note

Introduces a typed error model for CLOB API responses and a utility to map backend payloads to structured errors.

  • Adds ClobApiErrorCode union and ClobApiError class with code, status, and details
  • Adds mapApiError(response, status) to construct ClobApiError from API responses
  • Removes legacy auth-related error constants

Written by Cursor Bugbot for commit ff8adbc. This will update automatically on new commits. Configure here.

Introduces a typed error model for CLOB API responses, making error handling more explicit and developer-friendly by mapping backend error codes to a dedicated ClobApiError class.
@Angel1945uwu Angel1945uwu requested a review from a team as a code owner January 6, 2026 13:02

return new ClobApiError(
message,
code as ClobApiErrorCode,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrecognized error codes bypass UNKNOWN_ERROR fallback

The mapApiError function only falls back to "UNKNOWN_ERROR" when response?.errorCode is nullish. If the backend returns an error code string that exists but isn't in the ClobApiErrorCode union (e.g., "TIMEOUT" or "NOT_FOUND"), that unrecognized value passes through and is unsafely cast with as ClobApiErrorCode. This violates the type safety promise and could cause exhaustive switch statements on error.code to have unhandled cases.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant