Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 332feb7

Browse files
committed
fix: improved error handling for MixedResponse
1. in the core, we were transmitting on the error message for error parts of a multi-part response 2. incorrect serialization of code blocks with a part error 3. in code block rendering, no recognition of error parts
1 parent 87ad7c4 commit 332feb7

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

packages/core/src/repl/exec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ async function semicolonInvoke(commands: string[], execOptions: ExecOptions): Pr
735735
return entity
736736
}
737737
} catch (err) {
738-
return err.message
738+
return err
739739
}
740740
})
741741

plugins/plugin-client-common/src/components/Content/Markdown/frontmatter.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ export function tryFrontmatter(
3232
}
3333
}
3434

35+
function stringifyError(response: Error) {
36+
return { code: isCodedError(response) ? response.code : 1, message: response.message }
37+
}
38+
3539
/** Blunt attempt to avoid serializing React bits */
3640
function reactRedactor(key: string, value: any) {
3741
if (key === 'tab') {
3842
return undefined
3943
} else if (key === 'block') {
4044
return undefined
45+
} else if (typeof value === 'object' && value.constructor === Error) {
46+
return stringifyError(value)
4147
} else {
4248
return value
4349
}
@@ -47,12 +53,7 @@ function encodePriorResponse(response: KResponse): { encoding: string; encodedRe
4753
return {
4854
encoding: 'base64+gzip',
4955
encodedResponse: Util.base64PlusGzip(
50-
JSON.stringify(
51-
response.constructor === Error
52-
? { code: isCodedError(response) ? response.code : 1, message: response.message }
53-
: response,
54-
reactRedactor
55-
)
56+
JSON.stringify(response.constructor === Error ? stringifyError(response) : response, reactRedactor)
5657
)
5758
}
5859
}

plugins/plugin-client-common/src/components/Views/Terminal/Block/Inputv2.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export default class Input<T1, T2, T3> extends StreamingConsumer<Props<T1, T2, T
307307
: isError(response)
308308
? 'error'
309309
: isMixedResponse(response)
310-
? response.find(_ => isXtermResponse(_) && _.code !== 0)
310+
? response.find(_ => (isXtermResponse(_) && _.code !== 0) || isError(_))
311311
? 'error'
312312
: 'done'
313313
: 'done'

0 commit comments

Comments
 (0)