Skip to content

Commit

Permalink
refactor: logging cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
drazisil committed Nov 2, 2021
1 parent f3b1b9c commit 40e1e40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions packages/lobby/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,10 @@ export class LobbyServer {
try {
return npsSocketWriteIfOpen(connection, responsePacket.serialize());
} catch (error) {
process.exitCode = -1;
throw new Error(`Unable to send Connect packet: ${error}`);
if(error instanceof Error) {
throw new Error(`Unable to send Connect packet: ${error}`);
}
throw new Error(`Unable to send Connect packet: unknown error`)
}
}

Expand Down
10 changes: 5 additions & 5 deletions packages/transactions/src/tcp-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class TCPManager implements ITCPManager {
return this.socketWriteIfOpen(result.connection, responsePackets);
} catch (error) {
if (error instanceof Error) {
throw new TypeError(`Error in MC_TRACKING_MSG: ${error}`);
throw new TypeError(`Error in MC_TRACKING_MSG: ${error.message}`);
}

throw new Error("Error in MC_TRACKING_MSG, error unknown");
Expand All @@ -261,7 +261,7 @@ export class TCPManager implements ITCPManager {
return this.socketWriteIfOpen(result.connection, responsePackets);
} catch (error) {
if (error instanceof Error) {
throw new TypeError(`Error in MC_UPDATE_PLAYER_PHYSICAL: ${error}`);
throw new TypeError(`Error in MC_UPDATE_PLAYER_PHYSICAL: ${error.message}`);
}

throw new Error("Error in MC_UPDATE_PLAYER_PHYSICAL, error unknown");
Expand All @@ -279,7 +279,7 @@ export class TCPManager implements ITCPManager {
} catch (error) {
if (error instanceof Error) {
throw new TypeError(
`[TCPManager] Error writing to socket: ${error}`,
`[TCPManager] Error writing to socket: ${error.message}`,
);
}

Expand Down Expand Up @@ -320,7 +320,7 @@ export class TCPManager implements ITCPManager {
} catch (error) {
if (error instanceof Error) {
throw new TypeError(
`[TCPManager] Error writing to socket: ${error}`,
`[TCPManager] Error writing to socket: ${error.message}`,
);
}

Expand Down Expand Up @@ -363,7 +363,7 @@ export class TCPManager implements ITCPManager {
} catch (error) {
if (error instanceof Error) {
throw new TypeError(
`[TCPManager] Error writing to socket: ${error}`,
`[TCPManager] Error writing to socket: ${error.message}`,
);
}

Expand Down

0 comments on commit 40e1e40

Please sign in to comment.