I agree with you about don´t show SQL errors to a normal user
I forgot
to say that I am doing just now a part for an administrator user and I want
to show the error most clear as possible. Maybe I should use a log message.
Once it is defined that (tell me if I haven´t understood you):
a) I must do an extra request to the database in order to know if the user
exists to show the user the ActionMessages.
b) I must create a general page error for another errors (using
ModuleException, for example?)
Are the next steps correct?
1) Use the action methods for local errors. For local errors I mean the
errors which will be shown to the user at the same page where it is the
form.
2) Use the bean methods for general errors. For general error I mean an
error which will be shown at an error page. (using ModuleException).
Thanks
From: Dave Newton <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <user@struts.apache.org>
To: Struts Users Mailing List <user@struts.apache.org>
Subject: Re: Exceptions design
Date: Sun, 4 Feb 2007 09:41:23 -0800 (PST)
--- Francisco Exposito Aguilera wrote:
> What is the best way to show the user this sql
error?
I'm skeptical that you'd want to show the *user* an
SQL error; my experience has been that it's best to
wrap up such exceptions in an application-specific
exception and report a general system error (or even a
database error) and leave the specifics to a log
message, email or IM to the admin, etc.
> 2.Before execute the createUser bean method, execute
> another method to check if the user already exists.
> If it exists, use ActionMessages in the action
> class to show the error in the same createUser.jsp
> file.
>
> That means that if the user doesn´t exist, the
> action method will access, at least twice to the
> database, one for check if the user exists and one
> for create it.
I would think you'd have to do that anyway.
> java.sql.SQLException: ORA-00001: unique restriction
> (PK_USER) violated
>
> a) Primary key is violated (java.sql.SQLException:
> ORA-00001: unique
> restriction (PK_USER) violated)
>
> b) Name and both surnames are unique
> (java.sql.SQLException: ORA-00001:
> unique restriction (U_NAME_SURNAME1_SURNAME2_U)
> violated)
I would most certainly *not* expose *any* system
internals on a user-accessible web page.
> Depending on the exception, I want to show primary
> key exists or name and surnames exists with
another
> primary key
Useful for developer, useless for user.
All the *user* needs to know that another user with
the same username exists and they need to choose
another username or if they forgot their password they
can click here, etc.) Keep user messages simple and
jargon-free. It's easy enough to capture complete
failure info for the developer somewhere else.
(You can't restrict on just their real name because
people have the same names sometimes.)
d.
____________________________________________________________________________________
Don't get soaked. Take a quick peak at the forecast
with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_________________________________________________________________
Dale rienda suelta a tu tiempo libre. Mil ideas para exprimir tu ocio con
MSN Entretenimiento. http://entretenimiento.msn.es/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]