Skip to content

Commit

Permalink
feat(plugins/plugin-client-common): error messages should format as m…
Browse files Browse the repository at this point in the history
…arkdown

Fixes #5943
  • Loading branch information
starpit committed Oct 12, 2020
1 parent d049dcb commit 276575a
Showing 1 changed file with 17 additions and 16 deletions.
Expand Up @@ -91,11 +91,25 @@ export default class Scalar extends React.PureComponent<Props, State> {
return <React.Fragment />
} else if (typeof response === 'number') {
return <pre>{response}</pre>
} else if (typeof response === 'string') {
// Markdown interpretes escapes, so we need to double-escape
} else if (isUsageError(response)) {
// hopefully we can do away with this shortly
if (typeof response.raw === 'string') {
return <pre>{response.raw}</pre>
} else if (isMessageWithUsageModel(response.raw) || isMessageWithCode(response.raw)) {
return <pre>{response.raw.message}</pre>
} else {
return <HTMLDom content={response.raw} />
}
} else if (isXtermResponse(response)) {
return <XtermDom response={response} />
} else if (typeof response === 'string' || isError(response)) {
const message = isError(response) ? response.message : response
console.error('!!!!!!', message)

// Markdown interprets escapes, so we need to double-escape
return (
<pre>
<Markdown tab={tab} repl={tab.REPL} source={response.replace(/\\/g, '\\\\').replace(/\n/g, '\n\n')} />
<Markdown tab={tab} repl={tab.REPL} source={message.replace(/\\/g, '\\\\').replace(/\n/g, '\n\n')} />
</pre>
)
} else if (isCommentaryResponse(response)) {
Expand Down Expand Up @@ -149,19 +163,6 @@ export default class Scalar extends React.PureComponent<Props, State> {
))}
</div>
)
} else if (isUsageError(response)) {
// hopefully we can do away with this shortly
if (typeof response.raw === 'string') {
return <pre>{response.raw}</pre>
} else if (isMessageWithUsageModel(response.raw) || isMessageWithCode(response.raw)) {
return <pre>{response.raw.message}</pre>
} else {
return <HTMLDom content={response.raw} />
}
} else if (isXtermResponse(response)) {
return <XtermDom response={response} />
} else if (isError(response)) {
return <React.Fragment>{response.message}</React.Fragment>
} else if (isReactResponse(response)) {
return response.react
} else if (isHTML(response)) {
Expand Down

0 comments on commit 276575a

Please sign in to comment.