better logging
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Elizabeth Hunt 2024-12-15 00:00:32 -08:00
parent 4fd40b1f9d
commit 643c75caa4
Signed by: simponic
GPG Key ID: 2909B9A7FF6213EE
2 changed files with 21 additions and 7 deletions

View File

@ -17,18 +17,30 @@ export const main = (port: number) => {
jobInsensitive.to.username = "****REDACTED****";
jobInsensitive.to.password = "****REDACTED****";
const uuid = crypto.randomUUID();
ConsoleLogger.log(
`Received email job: ${JSON.stringify(jobInsensitive)}`,
`[${uuid}] Received email job: ${JSON.stringify(jobInsensitive)}`,
)();
const performEmailTest = perform(job)();
return await performEmailTest
.then(() => {
return performEmailTest
.then((result) => {
if (result._tag === "Left") {
const error = result.left;
ConsoleLogger.log(
`[${uuid}] job failure due to ${error.message}`,
)();
return new Response(error.message, {
status: 400,
});
}
ConsoleLogger.log(`[${uuid}] success`)();
return Response.json({ success: true });
})
.catch((error) => {
return new Response(error.message, {
status: 400,
.catch((e) => {
ConsoleLogger.log(`[${uuid}] internal failure due to ${e}`)();
return new Response(e.message, {
status: 500,
});
});
}

View File

@ -192,7 +192,9 @@ const findEmailUidInInbox: FindEmailUidInInbox = (
TE.fold(
(e) =>
pipe(
TE.fromIO(ConsoleLogger.log(`failed; ${retries} retries left.`)),
TE.fromIO(
ConsoleLogger.log(`failed to find email; ${retries} retries left.`),
),
TE.chain(() =>
retries === 0
? TE.left(e)