tryExecuteAndNotify - How do I get the error from ...
# package-development
w
Anyone had any luck with
tryExecuteAndNotify
and your own controller returning an error message that shows up as a notification bottom right?
I am currently debugging this and trying to figure this out. The
error
is
undefined
but inside
data
there is a property called
error
which does have my problemDetail stuff ?! https://cdn.discordapp.com/attachments/1314559596739694623/1314560024034410557/image.png?ex=675436ed&is=6752e56d&hm=c80666104f358713fe437278a45923e5d9fc801bff73f0e3f928e7d9e75943c8&
@Markus Johansson or @Kevin Jump you got this working at all for you ?
OK its because my error is not an APIError which is determined if the error contains a name prop. For now I will just handle this myself manually, but a shame not to use the stuff already built into the CMS :S
m
@Warren Buckley I've been hitting the same issue, it would be nice if tryExecuteAndNotify would show the error if it was just a 400 (or any other error-isch code) with a string in the body. I ended up using the built-in ProblemDetailsBuilder in a controller base class when returning errors. Similar to this
Copy code
var problemDetails = new ProblemDetailsBuilder()
    .WithTitle("Error")
    .WithDetail(errorBody.Message)
    .Build();
return StatusCode(400,problemDetails);
8 Views