Closed slimee closed 10 months ago
The data transferred between the main process and a worker must be plain JSON. Any class instance information is lost. If you want to transfer a class
instance, you'll need to put a serialization and deserialization logic of your own in place. If you want to transfer an error class, maybe you can let your function return an object { success, error }
instead of throwing an exception, in combination with logic to turn your data and error message into plain JSON.
Figure an error of "type" CalculationError
And it's loaded and thrown from inside the workerpool:
The error propagates from inside the workerpool context to the caller context.
The statement
error instanceof CalculationError
is:Do you notice this behavior? How should I preserve the type of errors thrown through the workerpool context? Regards