1 Reply Latest reply on Aug 16, 2007 7:03 AM by Jan_Vissers

    How to store/hold the original exception thru DataServiceException

    Jan_Vissers
      I want to provide some useful information to my user as to what went wrong in the dataservice (DM) logic. This is exception trace I see in the logging:

      Caused by: java.sql.SQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a
      duplicate key value in a unique or primary key constraint or unique index identified by 'SQL070814105731220'
      defined on 'EMPLOYEE'.
      at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
      at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(Unknown Source)
      at org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeUpdate(Unknown Source)
      at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.jav a:2247)
      ... 25 more

      Caused by: java.sql.SQLException: The statement was aborted because it would have caused a duplicate key value
      in a unique or primary key constraint or unique index identified by 'SQL070814105731220' defined on 'EMPLOYEE'.
      at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
      at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
      ... 36 more

      07/08/14 11:02:48 [Flex] Error while completing transaction: flex.data.DataServiceException: Error occurred
      completing a transaction stacktrace=flex.data.DataServiceException: Error occurred completing a transaction
      at flex.data.DataServiceTransaction.doCommit(DataServiceTransaction.java:938)
      at flex.data.DataServiceTransaction.complete(DataServiceTransaction.java:979)
      at flex.data.DataService.serviceTransactedMessage(DataService.java:807)
      at flex.data.DataService.serviceMessage(DataService.java:418)
      at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1165)
      at flex.messaging.endpoints.AbstractEndpoint.serviceMessage(AbstractEndpoint.java:727)
      at flex.messaging.endpoints.rtmp.AbstractRTMPServer.dispatchMessage(AbstractRTMPServer.java: 816)
      at flex.messaging.endpoints.rtmp.NIORTMPConnection$RTMPReader.run(NIORTMPConnection.java:424 )
      at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPo olExecutor.java:665)
      at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolEx ecutor.java:690)
      at java.lang.Thread.run(Thread.java:619)

      Clearly the "Error occurred completing a transaction..." bit isn't that interesting to our user, whereas "The statement was aborted because it would have caused a duplicate key value in a unique or primary..." would mean more - or at least we could use that info to create a proper user fault message.

      My question is: how can we save/store the original exception and passed it on to the Flex?