mirror of
https://github.com/zhom/donutbrowser.git
synced 2026-04-23 04:16:29 +02:00
style: disable pointer events for toasts
This commit is contained in:
+1
-1
@@ -28,7 +28,7 @@ export default function RootLayout({
|
||||
>
|
||||
<CustomThemeProvider>
|
||||
<TooltipProvider>{children}</TooltipProvider>
|
||||
<Toaster />
|
||||
<Toaster className="pointer-events-none" />
|
||||
<WindowDragArea />
|
||||
</CustomThemeProvider>
|
||||
</body>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Extracts the root error message from nested error strings
|
||||
* Removes redundant "Failed to..." prefixes to show only the most specific error
|
||||
*/
|
||||
export function extractRootError(error: unknown): string {
|
||||
if (!error) return "Unknown error";
|
||||
|
||||
const errorStr = error instanceof Error ? error.message : String(error);
|
||||
|
||||
// Split by common error prefixes and take the last meaningful part
|
||||
const errorParts = errorStr.split(/Failed to [^:]+: /);
|
||||
const rootError = errorParts[errorParts.length - 1];
|
||||
|
||||
// Clean up any remaining nested structure
|
||||
const cleanError = rootError.replace(/^"([^"]+)"$/, "$1");
|
||||
|
||||
return cleanError || errorStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows error toast with cleaned error message
|
||||
*/
|
||||
export function showCleanErrorToast(error: unknown, prefix?: string) {
|
||||
const rootError = extractRootError(error);
|
||||
const message = prefix ? `${prefix}: ${rootError}` : rootError;
|
||||
|
||||
// Import dynamically to avoid circular dependencies
|
||||
import("./toast-utils").then(({ showErrorToast }) => {
|
||||
showErrorToast(message);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user