Skip to content

chore: align warning and error objects, add frame property #12326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 8, 2024

Conversation

dummdidumm
Copy link
Member

@dummdidumm dummdidumm commented Jul 6, 2024

Alternative to #12325 which consolidates things further by having a common base class for both warnings and errors. (Personally I prefer this PR right here over the other one)

This aligns warning and error objects to contain the same properties and have their toString methods return the same shape. It's implemented by warnings becoming class objects, too, and sharing the same base class with errors. It also adds back the frame property that got lost in the Svelte 4->5 transition. The only difference to Svelte 4 now is a slightly adjusted toString property (which is consistent between warnings and errors now) and a position property that contains a tuple of start/end offsets instead of a pos property only containing the start offset

closes #12151

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

This aligns warning and error objects to contain the same properties and have their toString methods return the same shape. It also adds back the `frame` property that got lost in the Svelte 4->5 transition. The only difference to Svelte 4 now is a slightly adjusted toString property (which is consistent between warnings and errors now) and a `position` property that contains a tuple of start/end offsets instead of a `pos` property only containing the start offset

closes #12151
This aligns warning and error objects to contain the same properties and have their toString methods return the same shape. It's implemented by warnings becoming class objects, too, and sharing the same base class with errors. It also adds back the `frame` property that got lost in the Svelte 4->5 transition. The only difference to Svelte 4 now is a slightly adjusted toString property (which is consistent between warnings and errors now) and a `position` property that contains a tuple of start/end offsets instead of a `pos` property only containing the start offset

closes #12151
Copy link

changeset-bot bot commented Jul 6, 2024

🦋 Changeset detected

Latest commit: 263610d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR


/** @typedef {{ start?: number, end?: number }} NodeLike */

export class InternalCompileError extends Error {
export class InternalCompileError extends CompileDiagnostic {
name = 'CompileError';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

side note: I would've called this "CompilerError" (note the additional r). Is "compile error" more correct? I stumble over that mentally each time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error is comming from the compiler, so I would call it a CompilerError. Not meaning there is something is wrong with the compiler, but the an error has been raised from compiler. thoughts?

@dummdidumm dummdidumm merged commit dba4aa3 into main Jul 8, 2024
9 checks passed
@dummdidumm dummdidumm deleted the consolidate-warnings-errors-v2 branch July 8, 2024 15:09
@Rich-Harris Rich-Harris mentioned this pull request Jul 10, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Svelte 5: Reintroduce frame/pos/toString() in compiler warnings
3 participants