Skip to content

Commit 12e74c6

Browse files
authored
Merge pull request #53 from martinlaukkanen/master
Bugfix for format error on batch response
2 parents 4736dd0 + df251f8 commit 12e74c6

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/js/WebApiClient.Core.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,19 @@
241241

242242
function FormatError (xhr) {
243243
if (xhr && xhr.response) {
244+
var response = ParseResponse(xhr);
245+
246+
if (response instanceof WebApiClient.BatchResponse) {
247+
var errors = "";
248+
if (response.errors.length > 0) {
249+
errors = response.errors.map(function(e) {
250+
return e.code + ": " + e.message;
251+
}).join("\n\r");
252+
}
253+
254+
return xhr.status + " - " + errors;
255+
}
256+
244257
var json = JSON.parse(xhr.response);
245258

246259
if (!WebApiClient.PrettifyErrors) {
@@ -388,7 +401,7 @@
388401

389402
var nextLink = GetNextLink(response);
390403
var pagingCookie = GetPagingCookie(response);
391-
404+
392405
// Since 9.X paging cookie is always added to response, even in queryParams retrieves
393406
// In 9.X the morerecords flag can signal whether there are more records to be found
394407
// In 8.X the flag was not present and instead the pagingCookie was only set if more records were available
@@ -533,7 +546,7 @@
533546

534547
var nextLink = GetNextLink(response);
535548
var pagingCookie = GetPagingCookie(response);
536-
549+
537550
// Since 9.X paging cookie is always added to response, even in queryParams retrieves
538551
// In 9.X the morerecords flag can signal whether there are more records to be found
539552
// In 8.X the flag was not present and instead the pagingCookie was only set if more records were available

0 commit comments

Comments
 (0)