Simplify apps/cli/ code
- config.ts: Convert arrow functions to function declarations - api-client.ts: Extract duplicated RPCLink logic into buildClient helper - format-error.ts: Add centralized ORPCError handling - complete-login.ts: Remove redundant error handling (now in formatError) - status.ts: Simplify formatRelativeTime, improve whitespace - create.ts: Rename validRoles to VALID_ROLES, add as const, early return - completions.ts: Derive Shell type from SUPPORTED_SHELLS array Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import { ORPCError } from "@orpc/client";
|
||||
|
||||
/**
|
||||
* Format an unknown error value into a string message.
|
||||
* Handles Error instances, strings, and other types safely.
|
||||
* Handles ORPCError, Error instances, strings, and other types safely.
|
||||
*/
|
||||
export function formatError(error: unknown): string {
|
||||
if (error instanceof ORPCError) {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- ORPCError.code is typed as any
|
||||
return `[${error.code}] ${error.message}`;
|
||||
}
|
||||
if (error instanceof Error) {
|
||||
return error.message;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user