-
Notifications
You must be signed in to change notification settings - Fork 16.9k
Description
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I agree to follow the Code of Conduct that this project adheres to.
- I have searched the issue tracker for a feature request that matches the one I want to file, without success.
Problem Description
The product I'm developing now implements a custom error for gRPC to make the error handling. Then, by passing the additional information for the errors made by gRPC to the renderer, I am trying to do a flexible display of error messages with the renderer.
For example, I am trying to use custom errors in the following situations
- display the ID of data that failed to be received
- Handle custom error codes contracted to the gRPC server
However, ipcRenderer.invoke does not allow to receive custom error generated on main process because this function make simple Error() instance with error message.
ipcRenderer.invoke = async function (channel, ...args) {
const { error, result } = await ipc.invoke(internal, channel, args);
if (error) {
throw new Error(`Error invoking remote method '${channel}': ${error}`);
}
return result;
};Proposed Solution
I don't fully understand the ipc.invoke process described in cpp. If ipc.invoke can return a error thrown by the main process directly, I think the following changes will satisfy my wishes.
ipcRenderer.invoke = async function (channel, ...args) {
const { error, result } = await ipc.invoke(internal, channel, args);
if (error) {
throw error;
}
return result;
};However, the information on the channel drops off. I'd like to come up with a solution here when how to handle custom error policy is decieded.
Alternatives Considered
Additional Information
If it's the current implementation in relation to the cpp part of the implementation, please let me know. I'm glad to see it. I'm also glad that this custom error policy is being used as an anti If it's a pattern, I'd be happy to point that out as well.