Skip to content

Commit 3c42871

Browse files
committed
feat: LOAPI-19 rethrow
1 parent b3c9fcf commit 3c42871

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/convert.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,20 @@ export async function convertTo(filename: string, format: string): Promise<strin
3636
await exec(`rm '/tmp/${outputFilename}'`);
3737
await cleanupTempFiles();
3838

39-
return getConvertedFilePath(logs.toString());
39+
try {
40+
const logsString = logs.toString();
41+
42+
return getConvertedFilePath(logsString);
43+
} catch (error) {
44+
if (
45+
error instanceof Error &&
46+
error.message.includes(`Cannot read properties of null (reading '1')`)
47+
) {
48+
throw new Error(`Cannot generate PDF preview for .${outputFilename.split('.').pop()} file`, {
49+
cause: error,
50+
});
51+
}
52+
53+
throw error;
54+
}
4055
}

0 commit comments

Comments
 (0)