private static Exception STSThrowSqlException(SqlException ex) { Exception STSsqlException = new Exception(); switch (ex.Number) { case -2: { STSsqlException = newException(STSWebConstants.STS_RequestTimeOut);//Connection timeout break; } case 18456: case 1326: { STSsqlException = newException(STSWebConstants.STS_LoginFailed);//login failed break; } case 4060: { STSsqlException = newException(STSWebConstants.STS_DataBaseNotAvailable);//if database is notfound break; } case 229: { STSsqlException = newException(STSWebConstants.STS_LoginCredentials);//login credentials check break; } case 2601: case 2627: { STSsqlException = newException(STSWebConstants.STS_UniqueKeyConstraint);//unique key voilation break; } case 547: { STSsqlException = newException(STSWebConstants.STS_ForeignKeyConstraint);//Foreign Keyvoilation. break; } default: { STSsqlException = newException(STSWebConstants.STS_UnKnowException);//any other exceptions break; } } return STSsqlException; }