Skip to content

Instantly share code, notes, and snippets.

@mrwizard82d1
mrwizard82d1 / SqlExceptionCreator
Created July 3, 2016 06:42 — forked from benjanderson/SqlExceptionCreator
Creates SqlException through reflection and sets ErrorMessage and ErrorCode. Be aware this reflects private functionality which is likely to change, do not use this in production code
public static class SqlExceptionCreator
{
public static SqlException Create(string message, int errorCode)
{
SqlException exception = Instantiate<SqlException>();
SetProperty(exception, "_message", message);
var errors = new ArrayList();
var errorCollection = Instantiate<SqlErrorCollection>();