On Nov 24, 2009, at 5:21 PM, Chuck Hill wrote: > > On Nov 24, 2009, at 2:17 PM, Anjo Krank wrote: > >> Not really sure of the messages can be useful, tough, as they use the name >> of the constraint: >> >> ERROR: duplicate key value violates unique constraint "bb" >> >> and not the key (postgres). So the end user probably won't know about this. >> But it may still be better than a real exception. > > Run the constraint name + entity name through the "validation exception to > nice message" part of Wonder. > > e.g. > LoginUser.uniqueUserName = "You have already registered under this user name." > > Where uniqueUserName is the constraint name. > > > Chuck
That'd be awesome on 5.4. EOEntity.indexNamed(foo). If only I could get an
index name... Look at what MySQL returns for a table with a two column unique
index:
EvaluateExpression failed:
<com.webobjects.jdbcadaptor._MySQLPlugIn$MySQLExpression: "INSERT INTO
Parent(parentLastName, id, parentName) VALUES (?, ?, ?)" withBindings:
1:"bil-ly"(parentLastName), 2:9(id), 3:"blanks"(parentName)>:
Next exception:SQL State:23000 -- error code: 1062 -- msg: Duplicate entry
'blanks-bil-ly' for key 2
What a disaster... Even if I wanted to parse that to construct an error
message, I don't get all the keys that are required by the unique constraint.
:-/
Anyway, I do have a question related to this: Is it possible to get a handle to
the eo in there? I can't find it in the db context or the throwable. Right
now, the best I can do is throw a
ERXValidationFactory.defaultFactory().createCustomException(null,
"UniqueConstraintException");
and return a message like
"Could not save your changes: The value was not unique."
I suppose that's better than crashing, but it's not exactly helpful either.
Perhaps I could reconstruct the object in a disposable ec from the failed
AdaptorOperation and pass that 'clone' object to the validation factory? Or is
that asking for trouble? If I could just get
"Parent.parentName.UniqueConstraintException" I could at least make a
reasonable assumption about the unique constraint in some/most cases.
Ramsey
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
