If an error is thrown as a result of executing a handler on the main process, a response is returned across the IPC bridge with an object containing { error: true }. Then on the renderer side, in the invoke util, the function watches for truthy values of error, and if it sees one, it throws the response.
However, in the snapshot manager, we return objects that include an error field, which ends up getting thrown by the invoke util. This is probably not intended behavior -- I'd lean toward establishing a pattern where unrecoverable or unintended errors are thrown, and recoverable errors are returned on the response body.
To avoid this, I wrapped successful responses in { error: false, data: object } and returned the response body on the data field instead.
If an error is thrown as a result of executing a handler on the main process, a response is returned across the IPC bridge with an object containing
{ error: true }
. Then on the renderer side, in theinvoke
util, the function watches for truthy values oferror
, and if it sees one, it throws the response.However, in the snapshot manager, we return objects that include an
error
field, which ends up getting thrown by theinvoke
util. This is probably not intended behavior -- I'd lean toward establishing a pattern where unrecoverable or unintended errors are thrown, and recoverable errors are returned on the response body.To avoid this, I wrapped successful responses in
{ error: false, data: object }
and returned the response body on thedata
field instead.