MCPcopy Create free account
hub / github.com/DanWahlin/CustomerManagerStandard / createError

Function createError

CustomerManager/Scripts/breeze.debug.js:16360–16402  ·  view source on GitHub ↗
(error, url)

Source from the content-addressed store, hash-verified

16358 }
16359
16360 function createError(error, url) {
16361 // OData errors can have the message buried very deeply - and nonobviously
16362 // this code is tricky so be careful changing the response.body parsing.
16363 var result = new Error();
16364 var response = error && error.response;
16365 if (!response) {
16366 // in case DataJS returns "No handler for this data"
16367 result.message = error;
16368 result.statusText = error;
16369 return result;
16370 }
16371 result.message = response.statusText;
16372 result.statusText = response.statusText;
16373 result.status = response.statusCode;
16374 // non std
16375 if (url) result.url = url;
16376 result.body = response.body;
16377 if (response.body) {
16378 var nextErr;
16379 try {
16380 var body = JSON.parse(response.body);
16381 result.body = body;
16382 // OData v3 logic
16383 if (body['odata.error']) {
16384 body = body['odata.error'];
16385 }
16386 var msg = "";
16387 do {
16388 nextErr = body.error || body.innererror;
16389 if (!nextErr) msg = msg + getMessage(body);
16390 nextErr = nextErr || body.internalexception;
16391 body = nextErr || body;
16392 } while (nextErr);
16393 if (msg.length > 0) {
16394 result.message = msg;
16395 }
16396 } catch (e) {
16397
16398 }
16399 }
16400 proto._catchNoConnectionError(result);
16401 return result;
16402 }
16403
16404 function getMessage(body) {
16405 var msg = body.message || "";

Callers 1

breeze.debug.jsFile · 0.85

Calls 1

getMessageFunction · 0.85

Tested by

no test coverage detected