Skip to content

Commit 099590e

Browse files
committed
Use <pre> tag for error messages in showErrorMessage dialog
...to preserve line breaks and use a monospace font so e.g. pre-commit errors are readable. Partially addresses #1407.
1 parent 5b5678b commit 099590e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/notifications.ts renamed to src/notifications.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Dialog, Notification, showErrorMessage } from '@jupyterlab/apputils';
22
import { TranslationBundle } from '@jupyterlab/translation';
3+
import * as React from 'react';
34

45
/**
56
* Build notification options to display in a dialog the detailed error.
@@ -18,9 +19,20 @@ export function showError(
1819
{
1920
label: trans.__('Show'),
2021
callback: () => {
21-
showErrorMessage(trans.__('Error'), error, [
22-
Dialog.warnButton({ label: trans.__('Dismiss') })
23-
]);
22+
showErrorMessage(
23+
trans.__('Error'),
24+
{
25+
// Render error in a <pre> element to preserve line breaks and
26+
// use a monospace font so e.g. pre-commit errors are readable.
27+
// Ref: https://github.com/jupyterlab/jupyterlab-git/issues/1407
28+
message: (
29+
<pre style={{ whiteSpace: 'pre-wrap', fontSize: '7pt' }}>
30+
{error.message || error.stack || String(error)}
31+
</pre>
32+
)
33+
},
34+
[Dialog.warnButton({ label: trans.__('Dismiss') })]
35+
);
2436
},
2537
displayType: 'warn'
2638
} as Notification.IAction

0 commit comments

Comments
 (0)