Adding better noConnection handling

This commit is contained in:
Fabian Stamm 2018-06-11 22:10:14 +02:00
parent 709c4646ca
commit 1cb87b051c
3 changed files with 9 additions and 3 deletions

View File

@ -127,7 +127,10 @@ var SecureFile = /** @class */ (function () {
return [2 /*return*/, res]; return [2 /*return*/, res];
case 4: case 4:
err_2 = _a.sent(); err_2 = _a.sent();
if (err_2 instanceof TypeError || err_2.errno === "ECONNREFUSED")
throw new NoConnection(); throw new NoConnection();
console.log(err_2);
throw err_2;
case 5: return [2 /*return*/]; case 5: return [2 /*return*/];
} }
}); });

View File

@ -72,7 +72,10 @@ export default class SecureFile {
let res = await fetch(this.Server + endpoint + query_str, { method: method, body: body, headers: myHeaders }); let res = await fetch(this.Server + endpoint + query_str, { method: method, body: body, headers: myHeaders });
return res; return res;
} catch (err) { } catch (err) {
if (err instanceof TypeError || err.errno === "ECONNREFUSED")
throw new NoConnection(); throw new NoConnection();
console.log(err);
throw err;
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "secure-file-wrapper", "name": "secure-file-wrapper",
"version": "1.0.10", "version": "1.0.11",
"main": "index.js", "main": "index.js",
"author": "Fabian Stamm <dev@fabianstamm.de>", "author": "Fabian Stamm <dev@fabianstamm.de>",
"license": "MIT", "license": "MIT",