claude-code-router
claude-code-router copied to clipboard
fix(server): handle exceptions in messages route
This PR includes two small but important fixes to improve the overall usability and robustness of the claude-code-router.
Changes:
-
Corrected Outdated Command in Status Message (
src/utils/status.ts)- The status message displayed by
ccr statuswas suggesting the outdated commandccr close. - This has been updated to the correct command,
ccr stop, to avoid user confusion and align with the current CLI implementation.
- The status message displayed by
-
Added Exception Handling for
/v1/messagesRoute (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
catchblock. Now, if an error occurs, the server will immediately respond with a500 Internal Server Errorstatus 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!