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

Error messages are swallowed #71

Closed
Prinzhorn opened this issue Dec 31, 2019 · 2 comments · Fixed by #132
Closed

Error messages are swallowed #71

Prinzhorn opened this issue Dec 31, 2019 · 2 comments · Fixed by #132
Labels
enhancement New feature or request

Comments

@Prinzhorn
Copy link

I'm not sure what the root cause is, maybe this needs to be fixed in prettier or svelte, but I'm not familiar enough with their architecture. You might know immediately where this belongs.

As mentioned in #70 I wasn't getting any meaningful error message. All I got was

[error] Unable to expand glob patterns: js/components/DetachableWindow.svelte !**/node_modules/** !./node_modules/** !**/.{git,svn,hg}/** !./.{git,svn,hg}/**
[error] Cannot read property 'line' of undefined

I was able to track this down to node_modules/svelte/compiler.js

	class CompileError extends Error {
	    toString() {
	        return `${this.message} (${this.start.line}:${this.start.column})\n${this.frame}`;
	    }
	}

where this.start is undefined. It should be this.loc.start. But I don't think something that obvious is a bug in svelte. Not sure what's going on here, since this is compiled from TypeScript.

Once I fixed the line I got

[error] js/components/DetachableWindow.svelte: <script> must have a closing tag
[error] > 1 | <script>
[error]     |        ^
[error]   2 |   import { onDestroy } from "svelte";
[error]   3 | 
[error]   4 |   let wrapperRef; (1:8)
[error] 1: <script>
[error]            ^
[error] 2:   import { onDestroy } from "svelte";
[error] 3: 

which helped a lot more.

@Conduitry Conduitry added the enhancement New feature or request label May 8, 2020
@ehrencrona
Copy link
Contributor

I could reproduce this and I agree with the analysis above. The start attribute on the error is removed in https://github.com/sveltejs/prettier-plugin-svelte/blob/master/src/index.ts#L33
I don't quite understand why that code does what it does though. We could change it to make an exception for CompileError, but it's quite possible it can just be removed.

@dummdidumm Do you know?

@dummdidumm
Copy link
Member

Honestly I don't know, I only started taking over the project recently. This PR added it, and it seems it did that for a reason, but I guess we can just delete the delete (hah).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants