Fix CLI verbose error formatting#1613
Conversation
Greptile SummaryThis PR replaces raw
Confidence Score: 4/5The change is narrowly scoped to the verbose/report error-display paths; it does not alter control flow, error handling logic, or any data written to disk or the network. Both call sites are updated consistently and the new helper correctly falls back from No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "Fix CLI verbose error formatting" | Re-trigger Greptile |
| let detail = "undefined"; | ||
| try { | ||
| detail = | ||
| typeof value === "string" | ||
| ? JSON.stringify(value) | ||
| : JSON.stringify(value) ?? String(value); | ||
| } catch { | ||
| detail = String(value); | ||
| } |
There was a problem hiding this comment.
The
detail variable is initialised to "undefined" but this value is never actually used: the try block always assigns detail (the nullish-coalescing fallback ensures a non-undefined string even when JSON.stringify returns JS undefined), and the catch block overwrites it with String(value). The dead initialiser is misleading because it suggests there is a path that produces the string "undefined" outside of the String(undefined) call.
| let detail = "undefined"; | |
| try { | |
| detail = | |
| typeof value === "string" | |
| ? JSON.stringify(value) | |
| : JSON.stringify(value) ?? String(value); | |
| } catch { | |
| detail = String(value); | |
| } | |
| let detail: string; | |
| try { | |
| detail = | |
| typeof value === "string" | |
| ? JSON.stringify(value) | |
| : JSON.stringify(value) ?? String(value); | |
| } catch { | |
| detail = String(value); | |
| } |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
What
Fix CLI verbose and report error logging so compiled Bun binaries print a compact stack trace instead of dumping bundled source context from the raw error object.
Why
console.error(err)can include noisy$bunfsbundled code frames in compiled CLI binaries, making--verboseoutput hard to read. Formatting the error explicitly preserves the stack plus useful Appwrite SDK fields likecode,type, andresponse.Testing
php example.php clicomposer lint-twignpm run buildinexamples/cligit diff --checkgetValidAccessToken()through the CLI helper after relogin; refresh succeeded and returned a freshopenid email profile account.adminaccess token while persisting the rotated credentials through the normal path.