C
C#2w ago
godless

How to skip exception

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