What's about using the payload parameter. If I understand correctly you want to pass information (error code) through the system without really modifying/using it. That's what payload is for and that's the reason why every constraints has to define one.
You could have payload classes for each error type. The specification does contain an example were the payload is used to pass the severity of a constraint along. The online documentation is unfortunately still missing this section.
The code could look like this:
Code:
@NotNull(payload=Error.Data.class)
where Error is defined as:
Code:
public class Error {
public static class Data implements Payload {
}
public static class Foo implements Payload {
}
public static class Bar implements Payload {
}
}
--Hardy