Skip to content
Snippets Groups Projects
Commit ee021b21 authored by buczekp's avatar buczekp
Browse files

minor: don't expose internal errors to users

SVN: 22174
parent c12fcc31
No related branches found
No related tags found
No related merge requests found
...@@ -32,9 +32,9 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException; ...@@ -32,9 +32,9 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.openbis.generic.shared.IServer; import ch.systemsx.cisd.openbis.generic.shared.IServer;
/** /**
* Translates deeply nested exceptions thrown on server side e.g. by Spring (like * Translates deeply nested exceptions thrown on server side e.g. by Spring that contain user
* {@link TransactionSystemException} or {@link DataAccessException}) into {UserFailureException} * readable error messages (like {@link TransactionSystemException} or {@link DataAccessException})
* with message taken from the root exception cause. * into {UserFailureException} with message taken from the root exception cause.
* <p> * <p>
* The most important reason why this advisor was introduced was to translate exceptions that happen * The most important reason why this advisor was introduced was to translate exceptions that happen
* just before commit/rollback of transactions, like {@link TransactionSystemException}. Such * just before commit/rollback of transactions, like {@link TransactionSystemException}. Such
...@@ -75,11 +75,14 @@ public class ServerExceptionTranslatingAdvisor extends DefaultPointcutAdvisor ...@@ -75,11 +75,14 @@ public class ServerExceptionTranslatingAdvisor extends DefaultPointcutAdvisor
{ {
return invocation.proceed(); return invocation.proceed();
} catch (NestedRuntimeException ex) } catch (NestedRuntimeException ex)
// e.g. TransactionSystemException, DataAccessException
{ {
// Deferred trigger may throw an exception just before commit. if (ex instanceof TransactionSystemException || ex instanceof DataAccessException)
// Message in the exception is readable for the user. {
throw new UserFailureException(ex.getMostSpecificCause().getMessage(), ex); throw new UserFailureException(ex.getMostSpecificCause().getMessage(), ex);
} else
{
throw ex; // don't expose query syntax errors etc.
}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment