fix(og.service): improve font loading error handling

- Updated the font loading logic in `OgService` to handle potential errors when checking file existence.
- Utilized optional chaining to ensure that the code does not throw an error if the stat call fails, enhancing reliability during font loading.

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2025-11-14 21:07:54 +08:00
parent 4e1b27625b
commit c107aa49b3

View File

@@ -94,7 +94,10 @@ export class OgService implements OnModuleDestroy {
async loadFonts() {
if (!this.geistFontPromise) {
for (const candidate of GeistFontCandidates) {
const stats = await stat(candidate)
const stats = await stat(candidate).catch(() => null)
if (!stats) {
continue
}
if (stats.isFile()) {
this.geistFontPromise = readFile(candidate)
break