File tree Expand file tree Collapse file tree 1 file changed +10
-17
lines changed Expand file tree Collapse file tree 1 file changed +10
-17
lines changed Original file line number Diff line number Diff line change @@ -28,28 +28,21 @@ export async function convertTo(filename: string, format: string): Promise<strin
2828
2929 // due to an unknown issue, we need to run command twice
3030 try {
31- logs = ( await exec ( cmd ) ) . stdout ;
31+ const { stdout, stderr} = await exec ( cmd ) ;
32+ logs = stdout || new Error ( stderr ) ;
3233 } catch ( e ) {
33- logs = ( await exec ( cmd ) ) . stdout ;
34+ const { stdout, stderr} = await exec ( cmd ) ;
35+ logs = stdout || new Error ( stderr ) ;
3436 }
3537
3638 await exec ( `rm '/tmp/${ outputFilename } '` ) ;
3739 await cleanupTempFiles ( ) ;
3840
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 ;
41+ if ( logs instanceof Error ) {
42+ throw new Error ( `Cannot generate PDF preview for .${ outputFilename . split ( '.' ) . pop ( ) } file` , {
43+ cause : logs ,
44+ } ) ;
5445 }
46+
47+ return getConvertedFilePath ( logs . toString ( ) ) ;
5548}
You can’t perform that action at this time.
0 commit comments