Workers - Preserve exception details in console logs
From the publisher
Console methods now preserve exception details in your Worker's logs. When your Worker logs an exception, the corresponding log entry includes the exception name, message, and stack. For example, your Worker can catch and log an exception: try { throw new Error("Deliberately created exception"); } catch (error) { console.error("caught exception:", error); } try { throw new Error("Deliberately created exception"); } catch (error) { console.error("caught exception:", error); } If you use Workers Observability, your log is automatically enriched with structured error information. The following example shows how the enriched log appears in the Cloudflare dashboard: The exception's stack trace appears directly in the log message.
Source Cloudflare DevelopersCC BY 4.0 · Publisher excerpt shortened and converted to plain text. Original source license applies.
Read full article

