Passing of custom exceptions for ray workers

I am currently raising a custom exception within Ray remote workers. The reason for wanting to use a custom exception is that I would like to relay back to the user fine-grained details about the reason for the error.

I can catch the my custom raised exception within main.py when trying on ray.get but I’m unable to access any of the member variables from my exception. I noticed that Ray creates an inherited class based on RayTaskError within the function as_instanceof_cause but this appears not to initialise my base exception class correctly.

So I was wondering whether I am missing something here or is it not possible to obtain the information from my custom exception when I worker fails. I noticed that there is the traceback_str variable in RayTaskError which I could use but I was after a cleaner way of getting precise details back when a worker fails.

Hmm, I think as_instance_of is really only built so that try: ... catch CustomError: ... works.

It doesn’t really initialize the base class correctly. Do you mind filing a feature request on github for this (maybe with some context on your use case?).

cc @eoakes I remember you developed this feature before. How did that go?

Thanks for the reply.

Yeah, no problem with submitting a git request for this feature.

There’s an open PR for this here:

@GarryW if you ended up opening a GitHub issue, could you link it on that PR please?