Skip to content

Commit

Permalink
Better
Browse files Browse the repository at this point in the history
  • Loading branch information
bwateratmsft committed Sep 12, 2024
1 parent 24fbc4c commit 2a0f45f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils/httpRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ export async function streamToFile(downloadUrl: string, fileName: string): Promi

writeStream.close();
} catch (error) {
throw new Error(`Failed to download ${downloadUrl}: ${(error as { cause: string }).cause ?? error}`);
// Sometimes the error has a cause field, sometimes a message, sometimes maybe neither
const errorText = (error as { cause: string }).cause ?? (error as { message: string }).message ?? error;
throw new Error(`Failed to download ${downloadUrl}: ${errorText}`);
}
}

Expand Down

0 comments on commit 2a0f45f

Please sign in to comment.