Skip to content
New issue

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

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

Already on GitHub? # to your account

Bad (or inconsistent) error message when compiled file is a directory #2700

Open
Tracked by #3921
osa1 opened this issue Aug 2, 2021 · 1 comment
Open
Tracked by #3921

Bad (or inconsistent) error message when compiled file is a directory #2700

osa1 opened this issue Aug 2, 2021 · 1 comment

Comments

@osa1
Copy link
Contributor

osa1 commented Aug 2, 2021

$ mkdir test
$ moc test
Is a directory

This is an uncaught OCaml exception printed directly. We should at least show the path that is a directory, otherwise things get difficult to debug in e.g. CI or build scripts.

It's also inconsistent with the error message when e.g. file is not found:

$ moc test
test: No such file or directory

In general it's a good idea to be as helpful as possible and show the problematic path.

I suggest we print

<input> is a directory

or

<input>: Is a directory

to be consistent with the error message when file does not exist.

@osa1
Copy link
Contributor Author

osa1 commented Aug 2, 2021

It seems like you can create a lexer for a non-existent file or a directory and it doesn't fail. It only fails when you ask for the next token. In moc, the line that throws this exception is

Parsing.parse (!Flags.error_detail) (parser lexer.Lexing.lex_curr_p) tokenizer lexer

It seems like error handling could be refactored a little bit. Normally user errors are in this format:

<location>: <error kind> <error code>, <error message>

"No such file" and "is a directory" errors don't follow this format.

@crusso crusso mentioned this issue Apr 4, 2023
79 tasks
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant