Summary
All hardware errors in the device router currently map to INTERNAL_SERVER_ERROR via withHardwareClient. As the frontend matures, it would benefit from more specific error codes to enable better UX (e.g., retry prompts for timeouts, conflict resolution for concurrent operations).
Current Behavior (helpers.ts)
withHardwareClient wraps all hardware failures in a generic INTERNAL_SERVER_ERROR:
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: errorMessage,
})
Proposed Improvement
Map known hardware error types to appropriate tRPC codes:
| Hardware Error |
tRPC Code |
Frontend UX |
| Connection timeout |
TIMEOUT |
"Device not responding, retry?" |
| Already priming |
CONFLICT |
"Priming already in progress" |
| Device unreachable |
PRECONDITION_FAILED |
"Check device connection" |
| Command rejected |
BAD_REQUEST |
Show specific rejection reason |
Implementation Notes
- Requires understanding the error types/codes that the hardware client throws
- Could be implemented by catching specific error types in
withHardwareClient or per-procedure
- Should be done when the frontend is ready to handle these codes — no value in adding granularity the client doesn't use yet
- Non-breaking: frontend currently treats all errors the same, so this is purely additive
Priority
Low — implement when frontend error handling becomes more sophisticated and needs to differentiate between error types.
🤖 Generated with Claude Code
Summary
All hardware errors in the device router currently map to
INTERNAL_SERVER_ERRORviawithHardwareClient. As the frontend matures, it would benefit from more specific error codes to enable better UX (e.g., retry prompts for timeouts, conflict resolution for concurrent operations).Current Behavior (helpers.ts)
withHardwareClientwraps all hardware failures in a genericINTERNAL_SERVER_ERROR:Proposed Improvement
Map known hardware error types to appropriate tRPC codes:
TIMEOUTCONFLICTPRECONDITION_FAILEDBAD_REQUESTImplementation Notes
withHardwareClientor per-procedurePriority
Low — implement when frontend error handling becomes more sophisticated and needs to differentiate between error types.
🤖 Generated with Claude Code