Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] It should be possible to manually create SqlException #35

Open
ashmind opened this issue Jun 1, 2017 · 1 comment
Open
Labels
💡 Enhancement Issues that are feature requests for the drivers we maintain.

Comments

@ashmind
Copy link

ashmind commented Jun 1, 2017

SqlException create methods are currently internal.
I would like some kind of create method to be public.

Rationale

Unit tests. There are various scenarios in which SqlException is handled differently than other kinds of exceptions, and being able to test those scenarios without actual database would be useful.

Related StackOverflow thread, How to throw a SqlException when needed for mocking and unit testing?, has 53 upvotes.

Potential API

class SqlException {
    // ...
    public SqlException(
        string message,
        SqlErrorCollection errorCollection,
        Guid clientConnectionId = Guid.Empty,
        Exception innerException = null
    )  { ... }
}

class SqlErrorCollection {
    // ...
    public SqlErrorCollection()  { ... }
    public SqlErrorCollection(params SqlError[] errors)  { ... }
}

class SqlError {
    // ...
    public SqlError(
        int infoNumber,
        byte errorState,
        byte errorClass,
        string server,
        string errorMessage,
        string procedure,
        int lineNumber
    ) { ... }
}

Open Questions

Is there a better way to expose SqlError that would allow easier future extensibility?
Some kind of SqlErrorBuilder?

@divega
Copy link

divega commented May 16, 2019

As recently announced in the .NET Blog, focus on new SqlClient features an improvements is moving to the new Microsoft.Data.SqlClient package. For this reason, we are moving this issue to the new repo at https://github.com/dotnet/SqlClient. We will still use https://github.com/dotnet/corefx to track issues on other providers like System.Data.Odbc and System.Data.OleDB, and general ADO.NET and .NET data access issues.

@divega divega transferred this issue from dotnet/corefx May 16, 2019
@David-Engel David-Engel added the 💡 Enhancement Issues that are feature requests for the drivers we maintain. label May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 Enhancement Issues that are feature requests for the drivers we maintain.
Projects
None yet
Development

No branches or pull requests

3 participants