From 76b79a829eab6aec08dbf2deb43c9409a200dd99 Mon Sep 17 00:00:00 2001 From: Andrey Platov <87076238+aplatoff@users.noreply.github.com> Date: Tue, 16 Nov 2021 17:17:04 +0100 Subject: [PATCH] do not crash on import error (#308) Signed-off-by: Andrey Platov --- server/front/src/app.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/front/src/app.ts b/server/front/src/app.ts index 9fe7d3da16..8932cc28e4 100644 --- a/server/front/src/app.ts +++ b/server/front/src/app.ts @@ -195,7 +195,8 @@ export function start (transactorEndpoint: string, elasticUrl: string, minio: Cl const cookie = req.query.cookie as string | undefined const attachedTo = req.query.attachedTo as Ref | undefined - console.log('importing from ', url) + console.log('importing from', url) + console.log('cookie', cookie) const options = cookie !== undefined ? { @@ -207,6 +208,11 @@ export function start (transactorEndpoint: string, elasticUrl: string, minio: Cl https.get(url, options, response => { console.log('status', response.statusCode) + if (response.statusCode !== 200) { + // eslint-disable-next-line @typescript-eslint/restrict-template-expressions + res.status(500).send(`server returned ${response.statusCode}`) + return + } const id = uuid() const contentType = response.headers['content-type'] const meta: ItemBucketMetadata = { @@ -249,7 +255,6 @@ export function start (transactorEndpoint: string, elasticUrl: string, minio: Cl }) } }) - // console.log(buffer.toString('base64')); }).on('error', function (err) { res.status(500).send(err) })