MCPcopy Index your code
hub / github.com/coder/mux / convertToSendMessageError

Method convertToSendMessageError

src/node/services/streamManager.ts:3425–3446  ·  view source on GitHub ↗

* Converts errors to strongly-typed SendMessageError

(error: unknown)

Source from the content-addressed store, hash-verified

3423 * Converts errors to strongly-typed SendMessageError
3424 */
3425 private convertToSendMessageError(error: unknown): SendMessageError {
3426 // Check for specific AI SDK errors using type guards
3427 if (LoadAPIKeyError.isInstance(error)) {
3428 return {
3429 type: "api_key_not_found",
3430 provider: "anthropic", // We can infer this from LoadAPIKeyError context
3431 };
3432 }
3433
3434 // TODO: Add more specific error types as needed
3435 // if (APICallError.isInstance(error)) {
3436 // if (error.statusCode === 401) return { type: "authentication", ... };
3437 // if (error.statusCode === 429) return { type: "rate_limit", ... };
3438 // }
3439 // if (RetryError.isInstance(error)) {
3440 // return { type: "retry_failed", ... };
3441 // }
3442
3443 // Fallback for unknown errors
3444 const message = getErrorMessage(error);
3445 return { type: "unknown", raw: message };
3446 }
3447
3448 /**
3449 * Categorizes errors for better error handling (used for event emission)

Callers 1

startStreamMethod · 0.95

Calls 1

getErrorMessageFunction · 0.90

Tested by

no test coverage detected