I was wondering if there is a general strategy that can be applied to show errors (or warnings etc.) in the validator.
I know there is the error
function, that take arguments like:
message
source
feature
Is it possible to call this function in a generic way that works at least most of the time? I know that there are people that call the function like:
error("MyMessage", eObject.eContainer(), eObject.eContainingFeature(), ...)
, however, this puts the error in the wrong place most of the times. Isn't it possible to just add an Error to the eObject
without caring about the features and stuff?
When I call it like this: error("MyMessage", eObject, eObject.eContainingFeature(), ...)
I get an Exception, because the feature and the eObject does not match.
I just found the answer. You can set the feature to null
.
So you can call the function like:
error("MyMessage", eObject, null, ...)