C
C#8mo ago
g0dless

How to skip exception

How to get code to work further if it has an exception
No description
5 Replies
Pobiega
Pobiega8mo ago
Try/catch Handle the exception in the catch
g0dless
g0dlessOP8mo ago
just how? tried it and it didnt worked
Pobiega
Pobiega8mo ago
Also, don't use .Result Use await Calling async code like that is asking for trouble
Jimmacle
Jimmacle8mo ago
try
{
the code that might throw an exception
}
catch (SomeExceptionType e)
{
the code you want to run if the exception happens
}
finally
{
code you want to run no matter what whether an exception is thrown or not
}
try
{
the code that might throw an exception
}
catch (SomeExceptionType e)
{
the code you want to run if the exception happens
}
finally
{
code you want to run no matter what whether an exception is thrown or not
}
you can also skip the (SomeExceptionType e) but it's not recommended to catch all exceptions, catch the exceptions that you expect to have to handle
g0dless
g0dlessOP8mo ago
thanks ❤️

Did you find this page helpful?