From 099590ed5a343f23dc3fdbee7a32c8a40f88da86 Mon Sep 17 00:00:00 2001 From: Joshua Bronson Date: Tue, 3 Jun 2025 21:09:27 -0400 Subject: [PATCH] Use
 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.
---
 src/{notifications.ts => notifications.tsx} | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
 rename src/{notifications.ts => notifications.tsx} (69%)

diff --git a/src/notifications.ts b/src/notifications.tsx
similarity index 69%
rename from src/notifications.ts
rename to src/notifications.tsx
index 89a84ed2e..94a57c1bb 100644
--- a/src/notifications.ts
+++ b/src/notifications.tsx
@@ -1,5 +1,6 @@
 import { Dialog, Notification, showErrorMessage } from '@jupyterlab/apputils';
 import { TranslationBundle } from '@jupyterlab/translation';
+import * as React from 'react';
 
 /**
  * Build notification options to display in a dialog the detailed error.
@@ -18,9 +19,20 @@ export function showError(
       {
         label: trans.__('Show'),
         callback: () => {
-          showErrorMessage(trans.__('Error'), error, [
-            Dialog.warnButton({ label: trans.__('Dismiss') })
-          ]);
+          showErrorMessage(
+            trans.__('Error'),
+            {
+              // Render error in a 
 element to preserve line breaks and
+              // use a monospace font so e.g. pre-commit errors are readable.
+              // Ref: https://github.com/jupyterlab/jupyterlab-git/issues/1407
+              message: (
+                
+                  {error.message || error.stack || String(error)}
+                
+ ) + }, + [Dialog.warnButton({ label: trans.__('Dismiss') })] + ); }, displayType: 'warn' } as Notification.IAction