Hi everybody.
I need to register custom exception, do i have implemented and
registerred ISqlExceptionConverter, as shown in NHibernate tests. But
when exception in code throws, it is not converted. My convertion code
even does not call.
My code is really simple:
try
{
using (ISession sess = OpenSession())
using (ITransaction tx = sess.BeginTransaction())
{
....
sess.Save(obj); // invalid object scheduled for inserting
.....
tx.Commit(); // exception raises here
}
}
catch (UniquenessViolationException ex)
{
// never came here, since exception was not converted and is of type
HibernateException
}
My ISqlExceptionConverter implementation:
public class SqlExceptionConverter : ISQLExceptionConverter
{
public Exception Convert(AdoExceptionContextInfo exInfo)
{
var sqlEx = ADOExceptionHelper.ExtractDbException
(exInfo.SqlException) as SqlException;
if (sqlEx != null)
{
if (sqlEx.Number == 2627)
return new
UniquenessViolationException(exInfo.Message, sqlEx,
exInfo.Sql);
}
return SQLStateConverter.HandledNonSpecificException
(exInfo.SqlException, exInfo.Message, exInfo.Sql);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---