TempleOS
TempleOS
Explore posts from servers
CC#
Created by TempleOS on 10/16/2023 in #help
❔ OnActionExecuted exception filter runs before exception is thrown and is never called
So I've found a bit more information about how the app is working. There was a custom class called FileCallbackResult inside of that class, it overwrites the ExecuteResultAsync. This indicates that the code that I'm expecting to throw an error r.Result?.Invoke(responseBodyWriter.AsStream()) ?? Task.CompletedTask at the result stage, but this explains why each of the other filter types would fail, and an exception filter didn't work either. The issue now is managing to get the error and handle the error before the response is sent to the client. This is an issue I am not sure how to solve.
26 replies
CC#
Created by TempleOS on 10/16/2023 in #help
❔ OnActionExecuted exception filter runs before exception is thrown and is never called
I removed the other filter as a test, no change, I modified to be an exception filter and still no change. The stack trace has some information, but still doesn't quite help me solve the core issue. The stack trace ends at the downloadCommand step.
26 replies
CC#
Created by TempleOS on 10/16/2023 in #help
❔ OnActionExecuted exception filter runs before exception is thrown and is never called
So by pipeline you're meaning only the filter pipeline, not some "magical term" in asp that I've never heard of
26 replies
CC#
Created by TempleOS on 10/16/2023 in #help
❔ OnActionExecuted exception filter runs before exception is thrown and is never called
Do you mind explaining this a bit further. The concept of different pipelines? It seems strange that if I throw the exception directly in the controller (just immediately, not in the same fashion as shown above), that it doesn't bubble to the other filter implementation.
You might have also configured exception handling elsewhere that prevents your filter from getting it
I'm kind of doubting it, but it's not impossible. It's a large app, but idk
26 replies
CC#
Created by TempleOS on 10/16/2023 in #help
❔ OnActionExecuted exception filter runs before exception is thrown and is never called
How are these two things functionally different?
26 replies
CC#
Created by TempleOS on 10/16/2023 in #help
❔ OnActionExecuted exception filter runs before exception is thrown and is never called
(The rethrow was just to see if it did throw and was detectable here, but I'm lost on why asp doesn't detect this)
26 replies
CC#
Created by TempleOS on 10/16/2023 in #help
❔ OnActionExecuted exception filter runs before exception is thrown and is never called
return ToActionResult(result, r => {
return new FileCallbackResult(
new MediaTypeHeaderValue(MedaiTypes.PDF);
async (response, _) => {
try {
await (r.Result?.Invoke(responseBodyWriter.AsStream()) ?? Task.CompletedTask);
}
catch (Exception e) {
throw e;
}
}
);
});
return ToActionResult(result, r => {
return new FileCallbackResult(
new MediaTypeHeaderValue(MedaiTypes.PDF);
async (response, _) => {
try {
await (r.Result?.Invoke(responseBodyWriter.AsStream()) ?? Task.CompletedTask);
}
catch (Exception e) {
throw e;
}
}
);
});
In this process, the exception is caught here, but it is never detected by asp, and never runs the exception filter. So, I'm not sure how to fix this.
26 replies
CC#
Created by TempleOS on 10/16/2023 in #help
❔ OnActionExecuted exception filter runs before exception is thrown and is never called
So I found a bit of an issue. I tried testing out throwing the error in the controller directly and it worked. However, the actual code passes through three layers. httpService -> documentGenerator -> downloadCommand -> controller All while the http service passes a stream down, and each layer passes the stream. So, it's almost as if /api doesn't ever get the thrown exception in this process. Which is strange to me.
26 replies