Add log type when error and warn
This commit is contained in:
parent
775b7b287b
commit
71432d7194
@ -8,6 +8,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"start": "ts-node-dev --respawn --transpile-only src/client.ts",
|
||||
"local": "ts-node-dev --respawn --transpile-only src/client.ts start -p local",
|
||||
"build": "tsc"
|
||||
},
|
||||
"repository": {
|
||||
|
@ -98,7 +98,7 @@ function initClient(options: any) {
|
||||
});
|
||||
|
||||
socket.on("connect_error", (e) => {
|
||||
console.log(
|
||||
console.error(
|
||||
`${clientLogPrefix} connect error:`,
|
||||
(e && e.message) || "something wrong"
|
||||
);
|
||||
@ -108,11 +108,11 @@ function initClient(options: any) {
|
||||
});
|
||||
|
||||
socket.on("disconnect", (reason) => {
|
||||
console.log(`${clientLogPrefix} disconnected: ${reason}!`);
|
||||
console.warn(`${clientLogPrefix} disconnected: ${reason}!`);
|
||||
});
|
||||
|
||||
socket.on("disconnect_exit", (reason) => {
|
||||
console.log(`${clientLogPrefix} disconnected and exited ${reason}!`);
|
||||
console.warn(`${clientLogPrefix} disconnected and exited ${reason}!`);
|
||||
socket?.disconnect();
|
||||
process.exit(1);
|
||||
});
|
||||
@ -133,6 +133,7 @@ function initClient(options: any) {
|
||||
tunnelRequest.pipe(localReq);
|
||||
|
||||
const onTunnelRequestError = (e: any) => {
|
||||
console.error("tunnel request error: ", e);
|
||||
tunnelRequest.off("end", onTunnelRequestEnd);
|
||||
localReq.destroy(e);
|
||||
};
|
||||
@ -164,7 +165,7 @@ function initClient(options: any) {
|
||||
};
|
||||
|
||||
const onLocalError = (error: any) => {
|
||||
console.log(error);
|
||||
console.error("local error:", error);
|
||||
localReq.off("response", onLocalResponse);
|
||||
socket?.emit("request-error", requestId, error && error.message);
|
||||
tunnelRequest.destroy(error);
|
||||
|
Loading…
Reference in New Issue
Block a user