C
C#6mo ago
godless

How to skip exception

How to get code to work further if it has an exception
No description
5 Replies
Pobiega
Pobiega6mo ago
Try/catch Handle the exception in the catch
godless
godlessOP6mo ago
just how? tried it and it didnt worked
Pobiega
Pobiega6mo ago
Also, don't use .Result Use await Calling async code like that is asking for trouble
Jimmacle
Jimmacle6mo 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
godless
godlessOP6mo ago
thanks ❤️
Want results from more Discord servers?
Add your server