improve handling of unexpected toast errors

This commit is contained in:
Ruben Fiszel
2024-12-05 15:01:47 +01:00
parent 2c934cc3b8
commit 85df359c0a
+5 -1
View File
@@ -2,7 +2,11 @@
const pathRegex = /\b(u|f)\/[^\/\s]+\/[^\/\s]+\b/g
export function processMessage(message: string | undefined): string {
return (message ?? 'Error without message').replaceAll(pathRegex, (path) => {
return (
typeof message == 'string'
? message ?? 'Error without message'
: JSON.stringify(message, null, 2)
).replaceAll(pathRegex, (path) => {
return `<span class="bg-surface-secondary p-1 text-xs font-mono whitespace-nowrap rounded-md">${path}</span>`
})
}