Monday, November 19, 2018

Best way to handle DbException Messages / Format them for end user.

I am using the DbException.InnerException.Message when I catch DbExceptions in my .NET Core 2.1 app. Is there any way to take this information

"The INSERT statement conflicted with the FOREIGN KEY constraint \"FK_Customer_SitusCode_SitusCodeId\". The conflict occurred in database \"Alpha\", table \"Region.SitusCode\", column 'Id'.\nThe statement has been terminated." 

And turn it into something pretty like:

SitusCode '1' not found 
Best way to handle DbException Messages / Format them for end user. Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team