✅ is it okay to use try/catch for logic behavior?
for example here, what is better and why
10 Replies
The
Try....
pattern is preferred
Not only is it more concise to write and easier to read, it's also more performantis it because the
Try....
pattern doesn't throw exceptions?Well, yes
Huh? I thought throwing exceptions for expectable behavior is not a good idea?
That is also true
Because exceptions are slow and meant for actual invalid operations
Exceptions should be exceptional
Then why would
Uri.TryCreate
not be the answer here? I thought you should always try to use the proper methods to filter out possible wrong inputsIt is the answer here, yes
thanks for helping me