#18 Provide useful error messages when object validation fails

Next_Release
open
5
2013-07-26
2007-12-21
No

MyCoRe should provide helpful error messages when object validation fails, for example as reported by Robert:

Beim MyCoRe-Kern kam es zu einem Fehler, der verhinderte, daß die Anforderung zum Ende geführt werden konnte. Es folgt eine Fehlermeldung in Englisch, die nähere Datails dazu verrät, schicken Sie diese bitte an
den Systemadministrator. :

The given user object is not valid.

Stack trace :
org.mycore.common.MCRException: The given user object is not valid.
at org.mycore.user2.MCRUserMgr.createUser(MCRUserMgr.java:327)

MyCoRe does not say WHY the validation fails.
Many objects have a method isValid(), which works like this:

public boolean isValid() {
// bla bla
boolean test = true;
if( somethingWrong ) test = false;
return test;
}

When an object is checked, this method is used:

if (!user.isValid()) {
throw new MCRException("The given user object is not valid.");
}

There are 32 isValid() methods in the metadata and user datamodel, which could be changed like this:

public void checkValid() {
if( somethingWrong )
throw new MCRUsageException( "No primary group of user specified" );
}

Discussion

    • Group: MyCoRe_2.0 --> Next_Release_(example)