Heng Sin Low 2009-05-20 06:29:44 +00:00
parent 82e632660e
commit 257d12d77d
2 changed files with 40 additions and 20 deletions

View File

@ -168,6 +168,8 @@ public class DBException extends AdempiereException
* @param e exception
*/
public static boolean isChildRecordFoundError(Exception e) {
if (DB.isPostgreSQL())
return isSQLState(e, "23503");
return isErrorCode(e, 2292);
}
@ -186,4 +188,14 @@ public class DBException extends AdempiereException
public static boolean isInvalidUserPassError(Exception e) {
return isErrorCode(e, 1017);
}
/**
* Check if "time out" exception (aka ORA-01013)
* @param e
*/
public static boolean isTimeout(Exception e) {
if (DB.isPostgreSQL())
return isSQLState(e, "57014");
return isErrorCode(e, 1013);
}
} // DBException

View File

@ -36,6 +36,8 @@ import java.util.Properties;
import java.util.Vector;
import java.util.logging.Level;
import org.adempiere.exceptions.AdempiereException;
import org.adempiere.exceptions.DBException;
import org.compiere.db.CConnection;
import org.compiere.util.CLogMgt;
import org.compiere.util.CLogger;
@ -556,7 +558,10 @@ public class MSequence extends X_AD_Sequence
catch (Exception e)
{
s_log.log(Level.SEVERE, "(Table) [" + trxName + "]", e);
next = -2;
if (DBException.isTimeout(e))
throw new AdempiereException("GenerateDocumentNoTimeOut", e);
else
throw new AdempiereException("GenerateDocumentNoError", e);
}
finally
{
@ -838,7 +843,10 @@ public class MSequence extends X_AD_Sequence
catch (Exception e)
{
s_log.log(Level.SEVERE, "(DocType) [" + trxName + "]", e);
next = -2;
if (DBException.isTimeout(e))
throw new AdempiereException("GenerateDocumentNoTimeOut", e);
else
throw new AdempiereException("GenerateDocumentNoError", e);
}
finally
{