forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFbExceptionConverterExample.cs
33 lines (30 loc) · 1.02 KB
/
FbExceptionConverterExample.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using NHibernate.Exceptions;
namespace NHibernate.Test.ExceptionsTest
{
public class FbExceptionConverterExample : ISQLExceptionConverter
{
#region ISQLExceptionConverter Members
public Exception Convert(AdoExceptionContextInfo adoExceptionContextInfo)
{
var sqle = ADOExceptionHelper.ExtractDbException(adoExceptionContextInfo.SqlException) as DbException;
if (sqle != null)
{
if (sqle.ErrorCode == 335544466)
{
return new ConstraintViolationException(adoExceptionContextInfo.Message, sqle.InnerException, adoExceptionContextInfo.Sql, null);
}
if (sqle.ErrorCode == 335544569)
{
return new SQLGrammarException(adoExceptionContextInfo.Message, sqle.InnerException, adoExceptionContextInfo.Sql);
}
}
return SQLStateConverter.HandledNonSpecificException(adoExceptionContextInfo.SqlException, adoExceptionContextInfo.Message, adoExceptionContextInfo.Sql);
}
#endregion
}
}