Grokbase Groups Cayenne dev July 2007
Hi Ari,

As I've mentioned offline, I think that if an exception message is
set by the user, it may be a bad idea to clobber it
(CayenneRuntimeException 'getMessage()' kind of does it too, doh!).
The good news is that Cayenne internally uses a constructor without a
message: "ValidationException(ValidationResult)", so we can use the
code below to build an informative message:

private static String createMessage(ValidationResult result) {
// Ari's code goes here

public ValidationException(ValidationResult result) {
this(createMessage(result), result);

Do you think this'll work?


On Jul 9, 2007, at 1:05 PM, Aristedes Maniatis wrote:

Validation exception messages in three tier are pretty unhelpful by
the time they get to the client. We've been extending them by
adding this to ValidationException:

* Returns message that includes the details of the validation
public String getMessage() {
String message = super.getMessage();
if (result.hasFailures()) {
message = message + " validation failures: ";
for (int i = 0; i < result.getFailures().size(); i++) {
message = message + ((ValidationFailure)
if (i < result.getFailures().size() - 1) {
message = message + ", ";
return message;

Any thoughts about side effects this might have for anyone?

As an aside, what would be even more helpful is if three tier
returned not a CayenneRuntimeException, but a ValidationException
to the client. I don't know if that is hard to change.


Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001 fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
groupdev @
postedJul 9, '07 at 10:06a
activeJul 10, '07 at 9:20a



site design / logo © 2022 Grokbase