Skip to content

Commit

Permalink
chore: add page error log (#636)
Browse files Browse the repository at this point in the history
* chore: add page error log

* chore: install
  • Loading branch information
tea-artist committed May 30, 2024
1 parent 157730a commit 7ff21e4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 50 deletions.
2 changes: 0 additions & 2 deletions apps/nestjs-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@
"keyv": "4.5.4",
"knex": "3.1.0",
"lodash": "4.17.21",
"markdown-it": "14.1.0",
"markdown-it-sanitizer": "0.4.3",
"mime-types": "2.1.35",
"minio": "7.1.3",
"ms": "2.1.3",
Expand Down
25 changes: 15 additions & 10 deletions apps/nestjs-backend/src/features/mail-sender/mail-sender.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ export class MailSenderService {
@BaseConfig() private readonly baseConfig: IBaseConfig
) {}

async sendMail(mailOptions: ISendMailOptions): Promise<boolean> {
return this.mailService
.sendMail(mailOptions)
.then(() => true)
.catch((reason) => {
if (reason) {
this.logger.error(`Mail sending failed: ${reason.message}`, reason.stack);
}
return false;
});
async sendMail(
mailOptions: ISendMailOptions,
extra?: { shouldThrow?: boolean }
): Promise<boolean> {
const sender = this.mailService.sendMail(mailOptions).then(() => true);
if (extra?.shouldThrow) {
return sender;
}

return sender.catch((reason) => {
if (reason) {
this.logger.error(`Mail sending failed: ${reason.message}`, reason.stack);
}
return false;
});
}

inviteEmailOptions(info: { name: string; email: string; spaceName: string; inviteUrl: string }) {
Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs-app/src/pages/base/[baseId]/[tableId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ export const getServerSideProps: GetServerSideProps = withAuthSSR(async (context
};
} catch (e) {
const error = e as IHttpError;
if (error.status !== 401) {
if (error.status < 500) {
return {
notFound: true,
};
}
console.error(error);
throw error;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,16 @@ export const getServerSideProps = withAuthSSR<IViewPageProps>(async (context, ss
};
}
return {
err: '',
notFound: true,
};
} catch (e) {
const error = e as IHttpError;
if (error.status !== 401) {
if (error.status < 500) {
return {
err: '',
notFound: true,
};
}
console.error(error);
throw error;
}
});
Expand Down
5 changes: 2 additions & 3 deletions apps/nextjs-app/src/pages/base/[baseId]/[tableId]/design.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@ export const getServerSideProps = withAuthSSR<IDesignPageProps>(async (context,
};
}
return {
err: '',
notFound: true,
};
} catch (e) {
const error = e as IHttpError;
if (error.status !== 401) {
if (error.status < 500) {
return {
err: '',
notFound: true,
};
}
console.error(error);
throw error;
}
});
Expand Down
31 changes: 0 additions & 31 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7ff21e4

Please sign in to comment.