From c25ac2d6c0b4479031306834f0216d73f0ea93c9 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 4 Jul 2018 19:26:46 +0100 Subject: [PATCH] Improve error handling. --- src/api/EteSync.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/EteSync.ts b/src/api/EteSync.ts index 45fd0e6..bfb3d9e 100644 --- a/src/api/EteSync.ts +++ b/src/api/EteSync.ts @@ -338,7 +338,11 @@ class BaseNetwork { if (response.ok) { resolve(body); } else { - reject(new HTTPError(json.detail || json.non_field_errors)); + if (json) { + reject(new HTTPError(json.detail || json.non_field_errors || JSON.stringify(json))); + } else { + reject(new HTTPError(body)); + } } }).catch((error) => { reject(error);