Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Customizing error messages
Customizing error messages [message #893886] Thu, 05 July 2012 16:16 Go to next message
Eclipse UserFriend
Can anyone tell me how to show meaningful parser messages to the user? I want to know how it is done.

Thank you
Re: Customizing error messages [message #893896 is a reply to message #893886] Thu, 05 July 2012 17:03 Go to previous messageGo to next message
Eclipse UserFriend
Hmmm,

i am not quite sure what kind of problem you are targeting, never the
less you may have a look at ISyntaxErrorMessageProvider

~Christian
--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@xxxxxxxx
Re: Customizing error messages [message #893913 is a reply to message #893896] Thu, 05 July 2012 22:38 Go to previous messageGo to next message
Eclipse UserFriend
By meaningful messages i mean that when the parser fails to parse a string of text according to the grammar rules, it shows a weird syntax error message like "no viable input after ..." or "Expecting Rule XYZ..." stuff like that.

I wanted to customize them so that i can provide meaningful messages to the users.
Re: Customizing error messages [message #893921 is a reply to message #893913] Fri, 06 July 2012 01:15 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

this is what ISyntaxErrorMessageProvideris for - unfortunately you
will have to do a lot of reverse engineering to do the mapping of the
default messages to your messages.

~Christian
--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@xxxxxxxx
Re: Customizing error messages [message #894212 is a reply to message #893921] Sat, 07 July 2012 13:18 Go to previous message
Eclipse UserFriend
It is better to have a lenient and forgiving grammar and instead do
custom validation, this way you get full control over errors/warnings
and can even control what to flag as errors/warnings via user properties
if you want to.

You may even want to go as far as supporting illegal constructs in the
grammar where such constructs are common user mistakes just for the sake
of providing better feedback. As an example, if string are delimited
only by " " and user enters a string with ' ' - you can then easily
write a check for that, and provide a quickfix. If instead the first
single quote triggered a syntax error, you would have a very hard time
in the "error message provider" to translate the syntax-error to
something meaningful, and it would also be quite hard to provide a quick
fix (how do you know that what follows may be a string in an alternate
illegal form?)

Just my 2c

Regards
- henrik

On 2012-06-07 7:15, Christian Dietrich wrote:
> Hi,
>
> this is what ISyntaxErrorMessageProvideris for - unfortunately you will
> have to do a lot of reverse engineering to do the mapping of the default
> messages to your messages.
>
> ~Christian
Previous Topic:Excluding files from an MWE2 workflow
Next Topic:Possible Unicode Bug - Greek Polytonic
Goto Forum:
  


Current Time: Tue Jul 01 23:29:42 EDT 2025

Powered by FUDForum. Page generated in 0.04729 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top