Skip to content

Commit

Permalink
add custom message to abort error
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderKolberg committed Dec 8, 2023
1 parent 9d4aa13 commit ee1c65c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion _examples/golang-sse/webapp/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ const onMessage = (message: SubscribeMessagesReturn) => {

const onError = (error: WebrpcError) => {
console.error("onError()", error);
log.value = [...log.value, { type: "error", log: String(error) }];
if (error.message == "AbortError") {
log.value = [
...log.value,
{ type: "warn", log: "Connection closed by abort signal" },
];
} else {
log.value = [...log.value, { type: "error", log: String(error) }];
}
};

const onOpen = () => {
Expand Down
1 change: 1 addition & 0 deletions _examples/golang-sse/webapp/src/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ const sseResponse = async (
} else if (error instanceof DOMException && error.name === "AbortError") {
onError(
WebrpcRequestFailedError.new({
message: "AbortError",
cause: `AbortError: ${message}`,
})
);
Expand Down

0 comments on commit ee1c65c

Please sign in to comment.