wrap aws-sdk errors

because there are http errors with no message any error reading the
object is wrapped to conform to the @backstage/error assertError checks

Signed-off-by: Manuel Stein <manuel.stein@nokia-bell-labs.com>
This commit is contained in:
Manuel Stein
2022-07-22 18:43:44 +03:00
parent 5f36581151
commit c8196bd37d
3 changed files with 9 additions and 2 deletions
@@ -478,7 +478,7 @@ describe('AwsS3Publish', () => {
await expect(fails).rejects.toMatchObject({
message: expect.stringMatching(
/TechDocs metadata fetch failed; caused by Error: The file .* does not exist/i,
/TechDocs metadata fetch failed; caused by Error: .*/i,
),
});
});
@@ -49,7 +49,7 @@ const streamToBuffer = (stream: Readable): Promise<Buffer> => {
try {
const chunks: any[] = [];
stream.on('data', chunk => chunks.push(chunk));
stream.on('error', reject);
stream.on('error', (e: Error) => reject(new ForwardedError('Unable to read stream', e)));
stream.on('end', () => resolve(Buffer.concat(chunks)));
} catch (e) {
throw new ForwardedError('Unable to parse the response data', e);