2
Answers

How to return 500 internal server error to class response

Hi all,

Am having Employee class inthat there are two properties 

1. Emp name

2. Empid

Am going to insert the details in db and returning employee class as response

Public async Task<employee> save data(employee request)
{
Try
{
Return await insertasync(request);
}
Catch(exception ex)
{
Return new employee();
}

Above codes return always 200 success code even if error occurs 

How can I return 500 error response to the method

Can anyone let me know

Answers (2)