-
Notifications
You must be signed in to change notification settings - Fork 11
Returning errors from mirai #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Having looked at the following I believe the answer is that the |
Hi James, that's correct if you error in a mirai it returns a 'miraiError', which is just a classed character string. It's designed so it's easy to handle without requiring everything to be wrapped in a tryCatch. You can still get the trace back at $trace.back on the 'miraiError' object, but this is also currently just a list of character strings (for ease of handling). Are you looking for something like the ability for mirai to return a condition that can be re-thrown by rlang::abort() that includes all the context? I haven't looked into integration with rlang yet, but it could be something I consider. |
Hello, it may be better to explain what I was trying to achieve.
However, in some cases I need the ExtendedTask to stop before completion if certain conditions aren't met. I've actually managed to implement this solution by placing the file name into the error string that gets returned but that's not particularly robust or flexible as a solution. It seems to me that being able to return an error with extra metadata in the way that It's possible I'm missing something though? I didn't start working with |
Can you share how you’re using |
Thanks! Part of my code tries to process an uploaded file within a If the file that was uploaded can't be processed correctly for some reason I might stop the
Then later, in an
This is a very stripped down version of the code; in real use cases it would be handy to include even more metadata within the |
@James-G-Hill thanks for the example. I'm about to merge a PR which causes a In case you need something more, feel free to re-open. |
Hello @shikokuchuo , thanks for that. I'm on leave from work for another week or so but will test this out on my return. |
Uh oh!
There was an error while loading. Please reload this page.
After reading the documentation and then attempting to implement
mirai
withshiny::ExtendedTask
I am not clear whether I should usestop
orrlang::abort
within amirai
? I've attempted to do so and an error will be returned so it seems like it should work; however, when I usedrlang::abort
to return as more complex error the error is changed to asimple error
and any extra metadata is removed.Is this an oversight where
mirai
is removing theabort
metadata or is my whole method wrong?Edit: I've tested returning an
rlang::abort
from theshiny::ExtendedTask
when not wrapped inmirai
and it returns correctly, so it seems thatmirai
is the key part here.The text was updated successfully, but these errors were encountered: