I have my c# method , In the same I throwing exception in one of my case like below
throw new Exception("My Message");
And I am calling same endpoint from typescript , How can I get same message in typescript
When I am catching the exception in typescript like below code , I am not getting same message which is thrown in c#.
It is givingme standard internal server error .
catch(error => {
alert(error.response.data)
alert(error)

Rajeesh MenothPosted Feb 9, 2022, 9:42 AM
Mayur GujrathiPosted Feb 10, 2022, 10:23 AM
Arnab MukherjeePosted Feb 9, 2022, 1:05 PM
Use a generic response class to simplify the communication model.
Try to return the response from your C# method with a proper status and message format,
so that you can check the status = sussess or error and you can receive a success and error message also.
{
status:"error"
message: "invalid exception."
}
Now, call the C# endpoint from typescript and you will receive the same message here.
Muhammad Imran AnsariPosted Feb 9, 2022, 11:34 AM