Setting Property Constraint Error Message

Apologies if this is documented somewhere, or answered in another post.  I can't seem to find it.

I have a property constraint that checks if a property name matches a particular regular expression.  When the constraint fails, I want to set the error message to something sensible like "Property does not meet naming convention.  Must be in the format..." rather than the generic message "Error: Property constraint violation for...".  Is there a way to do this?

Thanks.

-jon

4 comments
Comment actions Permalink

Hi!

Try creating NonTypesystemRule instead of constraint. In this rule you can report errors/warnings by using

error "<message>" -> <node>;

warning ...;

expressions.

0
Comment actions Permalink

Perfect!

Thanks.

-jon

0
Comment actions Permalink
I've got the same problem here. I want to check the uniqueness of names. The names should be unique in all models, so I use the nodesIncludingImported operation. But these operation needs a Scope, which isn't available in a NonTypesystemRule.
Why isn't this error command of the typesystem available in constraints? I don't know what property constraints should be used for, if it is not possible to report a more meaningful message as "Property constraint violation".
0
Comment actions Permalink
You can use jetbrains.mps.project.GlobalScope.getInstance() as the scope for nodesIncludingImported.
0

Please sign in to leave a comment.