-
-
Notifications
You must be signed in to change notification settings - Fork 411
Closed
Description
Describe the feature / bug 📝:
Bug using Error in the return data strucutre of a promise.
While there is no error raise, the toast take the error branch with the following message HTTP error! status: undefined
Steps to reproduce the bug 🔁:
promise data structure return
export type Result<T, E = Error> =
| { ok: true; value: T }
| { ok: false; error: E };
export function Ok<T, E>(value: T): Result<T, E> {
return { ok: true, value };
}
export function Err<T, E>(error: E): Result<T, E> {
return { ok: false, error };
}
Code to reproduce the bug
async function whatWillHappen(): Promise<Result<null, Error>> {
return Err(new Error("Not implemented"));
}
export function useSaveProject() {
const handle = async () => {
toast.promise(whatWillHappen, {
loading: "Saving project...",
success: (result) => {
if (result.ok) {
return "Project saved";
} else {
return `Result Error: ${result.error}`;
}
},
error: (e) => `Error Raise: ${e}`,
});
};
return (handle);
}
This return:
Error Raise: HTTP error! status: undefined
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels