claude-code-router icon indicating copy to clipboard operation
claude-code-router copied to clipboard

fix(server): handle exceptions in messages route

Open GinWU05 opened this issue 6 months ago • 0 comments

This PR includes two small but important fixes to improve the overall usability and robustness of the claude-code-router.

Changes:

  1. Corrected Outdated Command in Status Message (src/utils/status.ts)

    • The status message displayed by ccr status was suggesting the outdated command ccr close.
    • This has been updated to the correct command, ccr stop, to avoid user confusion and align with the current CLI implementation.
  2. Added Exception Handling for /v1/messages Route (src/index.ts)

    • Previously, if a downstream API call (e.g., to OpenAI/DeepSeek) failed, the server would catch the exception but not send a response to the client. This caused the client's request to hang until it timed out.
    • An error handling mechanism has been added to the catch block. Now, if an error occurs, the server will immediately respond with a 500 Internal Server Error status and a JSON body containing the error details. This ensures the client receives a prompt and clear response upon failure.

These changes enhance the user experience and make the server's behavior more predictable and reliable.

Thank you for your review and consideration!

GinWU05 avatar Jun 30 '25 07:06 GinWU05