satya-das/cppparser

Error handling

Closed this issue · 6 comments

Is there a way to customize syntax error messages?

As of now there is none. But what kind of customization you are thinking about?

I was thinking of a way to customize the way that the line number is shown (filename:linenumber instead of line#number) and a way to customize the "beginning" of the error message. (Right now errors are prepended with "Error: ")

Adding filename in the error report can be done and is useful.
Can you provide the use case why you would like to change the beginning of the error message? You can certainly replace the error message with something else as part of post-processing. Is that not that possible in your use case?

Adding filename in the error report can be done and is useful.

Yes this would be great.

Can you provide the use case why you would like to change the beginning of the error message?

I want to prefix error messages with the name of the program. For instance:

cib: Error: ...

You can certainly replace the error message with something else as part of post-processing.

What do you mean by this?

I have made it possible to supply custom error handler with commit 5c417c6.
Please give it a try.
And indeed, your suggestion will actually help my cib project too. :).

Thank you! This is exactly the kind of customization I wanted.