C
C#2y ago
demndev

The best place to handle domain exceptions in an MVC app?

13 Replies
JakenVeina
JakenVeina2y ago
without any further context, I'm gonna have to say "don't use exceptions for normal control flow"
demndev
demndevOP2y ago
what to use instead? result objects?
Anton
Anton2y ago
you can catch them in a middleware
demndev
demndevOP2y ago
and do all checks about all type of exceptions?
Anton
Anton2y ago
probably make them inherit from a DomainException of sorts, so you can generalize it somewhat but yeah that's considered a bad pattern, because it becomes harder to track the logic flow
demndev
demndevOP2y ago
what about to make an exception filter for each controller action?
Anton
Anton2y ago
I wish c# had some syntax for result types to make them less verbose
demndev
demndevOP2y ago
yes…
Anton
Anton2y ago
yeah, I think that's actually better because you can use the MVC action result system then
demndev
demndevOP2y ago
good. probably I will use this approach
JakenVeina
JakenVeina2y ago
probably a good bet but it all depends on context
demndev
demndevOP2y ago
for what kind of context result objects will be better than exceptions?
JakenVeina
JakenVeina2y ago
most stuff in web land, for example
Want results from more Discord servers?
Add your server