Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Need file name and line number on syntax errors #51

Open
mrjbq7 opened this issue Jul 10, 2015 · 6 comments
Open

Need file name and line number on syntax errors #51

mrjbq7 opened this issue Jul 10, 2015 · 6 comments

Comments

@mrjbq7
Copy link

mrjbq7 commented Jul 10, 2015

I was trying to convert Factor's textmate bundle to work with Atom and had an error while running apm:

$ apm init --package atom --convert Factor.tmbundle

/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app/apm/node_modules/first-mate/lib/scope-selector-parser.js:954
      throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
            ^
SyntaxError: Expected ",", ".", [ \t], [*], [a-zA-Z0-9+_], [a-zA-Z0-9\-+_], [|&\-] or end of input but "\n" found.

This error didn't say which file, nor which position in the file was having the syntax error, which made debugging really difficult. By process of elimination, I was able to remove files until I found the offending file, which was this version:

https://github.com/slavapestov/factor/blob/70428241bd2f6f96e31b121690f337c466bed942/misc/Factor.tmbundle/Snippets/%5B%20expanded.tmSnippet

The fix was to remove the extra newline after source.factor (slavapestov/factor@2b1e7dd).

Anyway, it would be super awesome if you could add file/line/column to the error messages.

Thanks!

@izuzak
Copy link
Contributor

izuzak commented Jul 10, 2015

Thanks for the feedback, @mrjbq7.

@nathansobo you were looking at first-mate recently -- would we consider tweaking first-mate so that it extracts the line and column number from the pegjs exception and adds it to the exception message (probably here)? Or should we just tweak apm to do that when it calls first-mate?

@nathansobo
Copy link
Contributor

It makes sense to modify first mate to get that information. I'm somewhat surprised it's not already in the error message. We should just catch the exception and build/rethrow a new one with a better message.

FrederickGeek8 added a commit to FrederickGeek8/apm that referenced this issue Jul 18, 2017
@FrederickGeek8
Copy link

FrederickGeek8 commented Jul 18, 2017

I know this is an old issue but it is still open and unresolved, so I thought I'd try my hand at trying to fix it. I decided to apply the fix in APM since the information required to locate the source of the error is not made available to first-mate.

Additionally, it appears to be near impossible (or at least efficient) to ascertain an exact location of an error, so I elected to output the malformed piece of text instead, which should hopefully give enough information to the user to debug their program.

@Ingramz
Copy link
Contributor

Ingramz commented Jul 18, 2017

Seems to be duplicate of #23

@Ingramz Ingramz marked this as a duplicate of #23 Jul 18, 2017
@mrjbq7
Copy link
Author

mrjbq7 commented Jul 18, 2017

I was not complaining about receiving the syntax error (that was just an example). Instead I was suggesting debugging it was hard without file name and line numbers available. I don't think this issue is duplicate of #23.

@Ingramz
Copy link
Contributor

Ingramz commented Jul 18, 2017

From first-mate's perspective it is the same as #23, if not duplicate, then certainly related. Conversion takes place in apm (and first-mate never sees the complete file being converted, thus being oblivious of any sort of positional information), which @FrederickGeek8 has taken care of in his pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants