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

dx: better error messages for 'relative import path not prefixed with / or ./ or ../.' #3405

Merged
merged 2 commits into from
Nov 26, 2019

Conversation

bartlomieju
Copy link
Member

As suggested by @kevinkassimo (thanks!) in #3402 this PR introduces better error message for bad import prefix errors.

Before:

error: Uncaught ImportPrefixMissing: relative import path "baz" not prefixed with / or ./ or ../
► $deno$/dispatch_json.ts:40:11
    at DenoError ($deno$/errors.ts:20:5)
    at unwrapResponse ($deno$/dispatch_json.ts:40:11)
    at sendAsync ($deno$/dispatch_json.ts:91:10)

After:

error: Uncaught ImportPrefixMissing: relative import path "baz" not prefixed with / or ./ or ../. Imported from file:https:///Users/biwanczuk/dev/deno/cli/tests/type_definitions/bar.d.ts
► $deno$/dispatch_json.ts:40:11
    at DenoError ($deno$/errors.ts:20:5)
    at unwrapResponse ($deno$/dispatch_json.ts:40:11)
    at sendAsync ($deno$/dispatch_json.ts:91:10)

@@ -1,4 +1,4 @@
[WILDCARD]error: Uncaught ImportPrefixMissing: relative import path "bad-module.ts" not prefixed with / or ./ or ../
[WILDCARD]error: Uncaught ImportPrefixMissing: relative import path "bad-module.ts" not prefixed with / or ./ or ../. Imported from [WILDCARD]/error_011_bad_module_specifier.ts
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this may expose homeDir without --allow-env flag?

Copy link
Member Author

Choose a reason for hiding this comment

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

It will print full path to file just like any other error. So yes, it does "expose" home dir, but Deno dies on errors anyway

core/module_specifier.rs Outdated Show resolved Hide resolved
Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM

@ry ry merged commit 9712e0c into denoland:master Nov 26, 2019
@bartlomieju bartlomieju deleted the dx-import_prefix_missing branch November 26, 2019 17:14
bartlomieju added a commit to bartlomieju/deno that referenced this pull request Dec 28, 2019
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.

None yet

3 participants