Skip to content
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

Combine CLI Errors. #2487

Merged
merged 10 commits into from Jun 20, 2019

Conversation

2 participants
@kitsonk
Copy link
Contributor

commented Jun 10, 2019

Resolves #2474

Outside of core::JSError, all other Deno errors are now combined to be just DenoError.

I need to do further work on this PR, but wanted to get it visible to get any early feedback. Things I still need to do:

  • cli/errors.rs has no tests at all, add tests
  • Align the display of JSError (JSErrorColor) to be more like TypeScript diagnostics
  • Align the display of the other Deno errors to be more like TypeScript diagnostics
  • Bubble up non-diagnostic errors in the compiler worker

@kitsonk kitsonk force-pushed the kitsonk:deno_error branch from 51d5baf to 3b3deb8 Jun 10, 2019

Show resolved Hide resolved cli/errors.rs Outdated
Show resolved Hide resolved cli/errors.rs Outdated

@kitsonk kitsonk force-pushed the kitsonk:deno_error branch 3 times, most recently from 9a7e219 to c7ee43d Jun 12, 2019

@kitsonk

This comment has been minimized.

Copy link
Contributor Author

commented Jun 17, 2019

Ok, I have taken some artistic license with the errors to try to unify them, as neither TypeScript nor a coloured version of JSError work very well universally.

The biggest change is I took a hint from Rust errors which look something like this:

error[E0053]: method `format_related_info` has an incompatible type for trait
   --> ../../cli/fmt_errors.rs:122:26

Where TypeScript pretty errors led with the file location of the error, that really breaks up being to read them because on average, we output very long file identifiers that identify local and remote resources.

A TypeScript error looks like this (but in colour):

error TS2322: Type '(o: T) => { v: any; f: (x: B) => string; }[]' is not assignable to type '(r: B) => Value<B>[]'.
  Types of parameters 'o' and 'r' are incompatible.
    Type 'B' is not assignable to type 'T'.
      'B' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.

► file:///Users/kkelly/github/deno/tests/error_003_typescript.ts:20:3

20   values: o => [
     ~~~~~~

  The expected type comes from property 'values' which is declared here on type 'C<B>'

    ► file:///Users/kkelly/github/deno/tests/error_003_typescript.ts:8:3

    8   values?: (r: T) => Array<Value<T>>;
        ~~~~~~


error TS2339: Property 't' does not exist on type 'T'.

► file:///Users/kkelly/github/deno/tests/error_003_typescript.ts:22:12

22       v: o.t,
              ^


Found 2 errors.

And a JavaScript error looks like this:

error: Uncaught Error: exception from mod1
► file:///Users/kkelly/github/deno/tests/subdir/mod1.ts:16:9

16   throw Error("exception from mod1");
           ^

    at throwsError (file:///Users/kkelly/github/deno/tests/subdir/mod1.ts:16:9)
    at foo (file:///Users/kkelly/github/deno/tests/error_002.ts:4:3)
    at file:///Users/kkelly/github/deno/tests/error_002.ts:7:1

Also, I have remapped the top line, start_column, end_column and line contents from JSErrors, so you get authored code instead of transpiled code.

@ry ry marked this pull request as ready for review Jun 17, 2019

@ry

This comment has been minimized.

Copy link
Collaborator

commented Jun 17, 2019

Why is the squiggly red in one place but teal in another

Screen Shot 2019-06-17 at 3 35 44 PM

I like the arrows

@kitsonk

This comment has been minimized.

Copy link
Contributor Author

commented Jun 17, 2019

That follow the TypeScript model, squiggly red for an error, and squiggly teal/cyan for non-errors, where it is indicating a reference of where something is defined.

I should be able to finish off the tests today and get it into a green state.

@kitsonk

This comment has been minimized.

Copy link
Contributor Author

commented Jun 18, 2019

For reference, Rust also uses cyan when underlining "help":

errors_rs_—_deno

@kitsonk kitsonk force-pushed the kitsonk:deno_error branch from 48bc592 to 4afaef9 Jun 18, 2019

@kitsonk kitsonk changed the title [WIP] Combine CLI Errors. Combine CLI Errors. Jun 18, 2019

@kitsonk

This comment has been minimized.

Copy link
Contributor Author

commented Jun 18, 2019

Ok, I think this is ready for a final review @ry.

I didn't tackle the other error kinds display, as these are intrinsically Rust errors and are generally handled differently (usually via a panic!()) which gives more Rust context by default.

Also, I didn't handle bubbling up the worker JavaScript errors. I suspect it would be more straightforward to do that in a seperate PR now that there is a unified error infrastructure.

@kitsonk kitsonk force-pushed the kitsonk:deno_error branch 2 times, most recently from e2bea3f to 7500a50 Jun 18, 2019

kitsonk added some commits Jun 10, 2019

@kitsonk kitsonk force-pushed the kitsonk:deno_error branch from 7500a50 to dea666c Jun 19, 2019

@ry
Copy link
Collaborator

left a comment

Just a couple nits - looks great!

Show resolved Hide resolved cli/msg.fbs
Show resolved Hide resolved cli/main.rs
Show resolved Hide resolved cli/errors.rs Outdated
Show resolved Hide resolved cli/errors.rs Outdated
Show resolved Hide resolved cli/errors.rs Outdated
Show resolved Hide resolved cli/errors.rs Outdated
Show resolved Hide resolved cli/errors.rs Outdated
Show resolved Hide resolved cli/fmt_errors.rs Outdated
Show resolved Hide resolved core/modules.rs

kitsonk added some commits Jun 20, 2019

@kitsonk

This comment has been minimized.

Copy link
Contributor Author

commented Jun 20, 2019

@ry feedback addressed (and I forgot to test the source line remapping in source map, though it was being covered by the integrations tests).

kitsonk added some commits Jun 20, 2019

@ry

ry approved these changes Jun 20, 2019

Copy link
Collaborator

left a comment

LGTM

@ry ry merged commit 425df50 into denoland:master Jun 20, 2019

3 checks passed

Travis CI - Pull Request Build Passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.