Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 35881e8

Browse filesBrowse files
hazzikfredericDelaporte
authored andcommitted
Backport fix null reference in tests with Npgsql 8
1 parent af1029e commit 35881e8
Copy full SHA for 35881e8

File tree

Expand file treeCollapse file tree

1 file changed

+8
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-8
lines changed
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System;
2-
using System.Data.Common;
32
using NHibernate.Exceptions;
3+
using Npgsql;
44

55
namespace NHibernate.Test.ExceptionsTest
66
{
@@ -10,23 +10,23 @@ public class PostgresExceptionConverterExample : ISQLExceptionConverter
1010

1111
public Exception Convert(AdoExceptionContextInfo exInfo)
1212
{
13-
var sqle = ADOExceptionHelper.ExtractDbException(exInfo.SqlException) as DbException;
14-
if (sqle != null)
13+
if (ADOExceptionHelper.ExtractDbException(exInfo.SqlException) is PostgresException pge)
1514
{
16-
string code = (string)sqle.GetType().GetProperty("Code").GetValue(sqle, null);
17-
15+
string code = pge.SqlState;
1816
if (code == "23503")
1917
{
20-
return new ConstraintViolationException(exInfo.Message, sqle.InnerException, exInfo.Sql, null);
18+
return new ConstraintViolationException(exInfo.Message, pge.InnerException, exInfo.Sql, null);
2119
}
20+
2221
if (code == "42P01")
2322
{
24-
return new SQLGrammarException(exInfo.Message, sqle.InnerException, exInfo.Sql);
23+
return new SQLGrammarException(exInfo.Message, pge.InnerException, exInfo.Sql);
2524
}
2625
}
26+
2727
return SQLStateConverter.HandledNonSpecificException(exInfo.SqlException, exInfo.Message, exInfo.Sql);
2828
}
2929

3030
#endregion
3131
}
32-
}
32+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.