From 1cb87b051c2de35c22cce5f9ae15ce3dcd0e5a79 Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Mon, 11 Jun 2018 22:10:14 +0200 Subject: [PATCH] Adding better noConnection handling --- index.js | 5 ++++- index.ts | 5 ++++- package.json | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 3c50fbb..a55d83e 100644 --- a/index.js +++ b/index.js @@ -127,7 +127,10 @@ var SecureFile = /** @class */ (function () { return [2 /*return*/, res]; case 4: err_2 = _a.sent(); - throw new NoConnection(); + if (err_2 instanceof TypeError || err_2.errno === "ECONNREFUSED") + throw new NoConnection(); + console.log(err_2); + throw err_2; case 5: return [2 /*return*/]; } }); diff --git a/index.ts b/index.ts index 702773a..aa22fc3 100644 --- a/index.ts +++ b/index.ts @@ -72,7 +72,10 @@ export default class SecureFile { let res = await fetch(this.Server + endpoint + query_str, { method: method, body: body, headers: myHeaders }); return res; } catch (err) { - throw new NoConnection(); + if (err instanceof TypeError || err.errno === "ECONNREFUSED") + throw new NoConnection(); + console.log(err); + throw err; } } diff --git a/package.json b/package.json index fa8aa3a..1d99570 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "secure-file-wrapper", - "version": "1.0.10", + "version": "1.0.11", "main": "index.js", "author": "Fabian Stamm ", "license": "MIT",