From 7bf8edbc9196446e2e4c8e4c137e52b37d67927f Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Fri, 10 Nov 2017 18:30:09 +0100 Subject: [PATCH] Now show missing file errors for multipart requests --- app/network/multipart.js | 17 +++++++++++++---- .../__tests__/grant-client-credentials.test.js | 1 - app/package.json | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/network/multipart.js b/app/network/multipart.js index 4ed139e37..7ebe8bdaf 100644 --- a/app/network/multipart.js +++ b/app/network/multipart.js @@ -14,9 +14,14 @@ export async function buildMultipart (params: Array) { const lineBreak = '\r\n'; let totalSize = 0; - async function addFile (path: string) { - return new Promise(resolve => { - const {size} = fs.statSync(path); + function addFile (path: string): Promise { + return new Promise((resolve, reject) => { + let size; + try { + size = fs.statSync(path).size; + } catch (err) { + reject(err); + } const stream = fs.createReadStream(path); stream.once('end', () => { resolve(); @@ -56,7 +61,11 @@ export async function buildMultipart (params: Array) { addString(`Content-Type: ${contentType}`); addString(lineBreak); addString(lineBreak); - await addFile(fileName); + try { + await addFile(fileName); + } catch (err) { + return reject(err); + } } else { const name = param.name || ''; const value = param.value || ''; diff --git a/app/network/o-auth-2/__tests__/grant-client-credentials.test.js b/app/network/o-auth-2/__tests__/grant-client-credentials.test.js index f592025d5..7286da8c4 100644 --- a/app/network/o-auth-2/__tests__/grant-client-credentials.test.js +++ b/app/network/o-auth-2/__tests__/grant-client-credentials.test.js @@ -22,7 +22,6 @@ describe('client_credentials', () => { } })); - // console.log('GET TOKEN', getToken); const result = await getToken( 'req_1', ACCESS_TOKEN_URL, diff --git a/app/package.json b/app/package.json index 16b753e71..f70373daf 100644 --- a/app/package.json +++ b/app/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "insomnia", - "version": "5.11.4", + "version": "5.11.5", "productName": "Insomnia", "longName": "Insomnia REST Client", "description": "Debug APIs like a human, not a robot",