Skip to content

Commit

Permalink
improve logging in a few places
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Dec 9, 2024
1 parent 73aa616 commit 9a830f5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
24 changes: 20 additions & 4 deletions src/routes/compact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ export async function setupCompactRoutes(
nonce: '0x' + nonce.toString(16).padStart(64, '0'),
};
} catch (error) {
server.log.error('Failed to generate nonce:', error);
server.log.error({
msg: 'Failed to generate nonce',
err: error instanceof Error ? error.message : String(error),
path: request.url,
});
reply.code(500);
return {
error:
Expand Down Expand Up @@ -118,7 +122,11 @@ export async function setupCompactRoutes(
request.session.address
);
} catch (error) {
server.log.error('Failed to submit compact:', error);
server.log.error({
msg: 'Failed to submit compact',
err: error instanceof Error ? error.message : String(error),
path: request.url,
});
if (
error instanceof Error &&
error.message.includes('Sponsor address does not match')
Expand Down Expand Up @@ -150,7 +158,11 @@ export async function setupCompactRoutes(
try {
return await getCompactsByAddress(server, request.session.address);
} catch (error) {
server.log.error('Failed to get compacts:', error);
server.log.error({
msg: 'Failed to get compacts',
err: error instanceof Error ? error.message : String(error),
path: request.url,
});
if (
error instanceof Error &&
error.message.includes('No compacts found')
Expand Down Expand Up @@ -201,7 +213,11 @@ export async function setupCompactRoutes(

return serializedCompact;
} catch (error) {
server.log.error('Failed to get compact:', error);
server.log.error({
msg: 'Failed to get compact',
err: error instanceof Error ? error.message : String(error),
path: request.url,
});
reply.code(500);
return {
error:
Expand Down
5 changes: 4 additions & 1 deletion src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,10 @@ export async function validateAndCreateSession(

return session;
} catch (error) {
server.log.error('Session validation failed:', error);
server.log.error({
msg: 'Session validation failed',
err: error instanceof Error ? error.message : String(error),
});
throw error;
}
}
Expand Down

0 comments on commit 9a830f5

Please sign in to comment.