Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database error handling in entity framework

I wrote stored procedure witch sometimes RAISERROR(). I execute it through the entity framework like:

using( MyModelEntities conn = new MyModelEntities() ) {
    conn.MyStoredProcedure(input_p, output_p);
}

Stored procedure:

create procedure dbo.MyStoredProcedure(
    @input   nvarchar(255),
    @output int out
)
as
begin
    ...
        RAISERROR (N'My Exception....', 10, 1);
    ...
end
go

Is there any opportunity to get information about error?

like image 618
nosbor Avatar asked May 01 '12 13:05

nosbor


2 Answers

In sql server exception level 1 to 10 are informational and does not raise error back to your application.

change Level in between 11 to 16 to raise error from the SP.

like image 133
Utkarsh Patel Avatar answered Sep 28 '22 04:09

Utkarsh Patel


Can this just be put into a try/catch with the exception displayed? Or maybe you could try going into debug mode?

like image 40
dweiss Avatar answered Sep 28 '22 04:09

dweiss