sveltejs / svelte

Cybernetically enhanced web apps
https://svelte.dev
MIT License
78.96k stars 4.15k forks source link

`CompileWarning` extends `Error` #13628

Closed Rich-Harris closed 3 days ago

Rich-Harris commented 5 days ago

Describe the bug

CompileWarning extends Error and I see no reason why it should — it should just be a POJO (maybe with a convenience toString() method). Found this while trying to postMessage a warning from a worker and finding the message got stripped out

Reproduction

later

Logs

No response

System Info

next

Severity

annoyance

dummdidumm commented 5 days ago

We talked about this a while back that error and warning should share the same shape and therefore we could also make them share the same base class. But yes it may make sense to revisit this.

trueadm commented 5 days ago

So are we saying that CompileDiagnostic shouldn't extend Error now? If so, we definitely spoke about this and agreed that we wanted this behaviour.

Rich-Harris commented 5 days ago

I don't recall that conversation, though I did apparently merge https://github.com/sveltejs/svelte/pull/12326. Why would we want warnings to extend Error? The user doesn't need to know the stack, that's just noise. (Honestly this is true for errors as well — how weird would it be if CompileError didn't extend Error?)