Get the return value from a JobResult, throwing an appropriate error if the result isn't a ValueResult.
The job result you want to unwrap. Must not be undefined!
The value if the result is a ValueResult, or a thrown error if it's an ErrorResult. A CancelError is thrown if the job was canceled, or the error in the result is thrown.
If the result is an error, it is marked as handled.
Get the return value from a JobResult, throwing an appropriate error if the result isn't a ValueResult.