Search
Get Started
C
C#
•
3y ago
demndev
The best place to handle domain exceptions in an MVC app?
C#
Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,010
Members
View on Discord
Was this page helpful?
Yes
No
J
JakenVeina
•
4/7/23, 5:54 PM
without any further context
, I
'm gonna have to say
"don
't use exceptions for normal control flow
"
J
JakenVeina
without any further context, I'm gonna have to say "don't use exceptions for nor...
D
demndev
OP
•
4/8/23, 4:06 AM
what to use instead
? result objects
?
D
demndev
Click to see attachment
A
Anton
•
4/8/23, 4:33 AM
you can catch them in a middleware
A
Anton
you can catch them in a middleware
D
demndev
OP
•
4/8/23, 4:34 AM
and do all checks about all type of exceptions
?
A
Anton
•
4/8/23, 4:34 AM
probably make them inherit from a
of sorts
, so you can generalize it somewhat
A
Anton
•
4/8/23, 4:36 AM
but yeah that
's considered a bad pattern
, because it becomes harder to track the logic flow
D
demndev
OP
•
4/8/23, 4:36 AM
what about to make an exception filter for each controller action
?
A
Anton
•
4/8/23, 4:37 AM
I wish c
# had some syntax for result types to make them less verbose
D
demndev
OP
•
4/8/23, 4:39 AM
yes
…
A
Anton
•
4/8/23, 4:39 AM
yeah
, I think that
's actually better
A
Anton
•
4/8/23, 4:39 AM
because you can use the MVC action result system then
D
demndev
OP
•
4/8/23, 4:40 AM
good
. probably I will use this approach
D
demndev
what to use instead? result objects?
J
JakenVeina
•
4/8/23, 4:56 AM
probably a good bet
J
JakenVeina
•
4/8/23, 4:56 AM
but it all depends on context
J
JakenVeina
but it all depends on context
D
demndev
OP
•
4/8/23, 5:01 AM
for what kind of context result objects will be better than exceptions
?
J
JakenVeina
•
4/8/23, 5:02 AM
most stuff in web land
, for example
DomainException
DomainException