开发者

jqgrid error Status: 'error'. Error code: 500 on add more meaningful message

I have a jqgrid which works fine. However there is a constraint in my database and I need to provide more meaningful validation method when adding.

The problem is when I submit the dialog shows the error: error Status: 'error'. Error code: 500

I would much prefer it to show the actual error caused by the exception thrown on save:

Violation of UNIQUE KEY constraint 'UKC_InvoiceId_ActivityId'. Cannot insert duplicate key in object 'dbo开发者_如何学编程.InvoiceLine'. The duplicate key value is (11, 1). The statement has been terminated.

Can anybody tell me how to achieve this?


If you use ASP.NET then you can use try {...} catch (SqlException ex) {...} block over the code which implement the row insertion. You can analyse ex.Procedure, ex.Server, ex.LineNumber, ex.Message values inside of the SqlException and generate (throw) another exception with more readable message. You can use in the error message the texts typed by the user and explain which data the user have to modify to solve the problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜