fix(core): preserve structured error messages (#33530)
This commit is contained in:
parent
10f6bb7878
commit
c17b9557f1
11 changed files with 73 additions and 9 deletions
|
|
@ -10,7 +10,14 @@ export class AppProcessError extends Schema.TaggedErrorClass<AppProcessError>()(
|
|||
exitCode: Schema.optional(Schema.Number),
|
||||
stderr: Schema.optional(Schema.String),
|
||||
cause: Schema.optional(Schema.Defect()),
|
||||
}) {}
|
||||
}) {
|
||||
override get message() {
|
||||
const detail =
|
||||
this.stderr?.trim() || (this.cause instanceof Error ? this.cause.message : this.cause && String(this.cause))
|
||||
const status = this.exitCode === undefined ? "" : ` (exit ${this.exitCode})`
|
||||
return `Command failed${status}: ${this.command}${detail ? `: ${detail}` : ""}`
|
||||
}
|
||||
}
|
||||
|
||||
export interface RunOptions {
|
||||
readonly maxOutputBytes?: number
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue