C
C#2y ago
fasadin

✅ Exception is caught, but not?

I have this piece of code
try
{
await _dbContext.RunningTotals.AddAsync(new RunningTotal
{
Value = runningTotalDto.Value
});

await _dbContext.SaveChangesAsync();

return new Result<OptionNone>(OptionNone.Default);
}
catch (Exception e)
{
return new Result<OptionNone>(e);
}
try
{
await _dbContext.RunningTotals.AddAsync(new RunningTotal
{
Value = runningTotalDto.Value
});

await _dbContext.SaveChangesAsync();

return new Result<OptionNone>(OptionNone.Default);
}
catch (Exception e)
{
return new Result<OptionNone>(e);
}
on await _dbContext.SaveChangesAsync(); I am getting exception. Breakpoint hits catch (Exception e) it goes into return new Result<OptionNone>(e); and then it just skips execution... it shows on IDE that exception is still present I don't understand nothing from it 😦
21 Replies
phaseshift
phaseshift2y ago
And what happens when you keep continuing?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
fasadin
fasadinOP2y ago
oh I am using Rider one moment exception is goes through application but anyway, this is "break when exception is called" what I am saying it's Exception after catch it's still present. Like there was no catch :/ that's why I am confused
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
phaseshift
phaseshift2y ago
Or better yet, a simple unit test that shows the exception escapes to the async caller
fasadin
fasadinOP2y ago
@TeBeConsulting @phaseshift sorry for late response. I didn't get notifications 😦 there you go recording 🙂
fasadin
fasadinOP2y ago
that will be difficult as this is connecting with DB
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
phaseshift
phaseshift2y ago
Why did you stop the recording there?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
fasadin
fasadinOP2y ago
there is lightning sign, which indicates that exception is "on going" one moment I will make new one
phaseshift
phaseshift2y ago
It's still in scope When you exit the method, then it will be gone
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
fasadin
fasadinOP2y ago
it's not
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
fasadin
fasadinOP2y ago
from LanguageExt object that it's "none" one moment 😄
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
fasadin
fasadinOP2y ago
hmmm ok you are guys right execution it's correct but that lightning was confusing to me because it does not disappear
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
fasadin
fasadinOP2y ago
😄 with one try-catch it's different behaviour then the other one 😐 at least I am not crazy 😌 thanks for reassurance 🙂 @TeBeConsulting @phaseshift
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server