Skip to content

Commit 20cf034

Browse files
authored
Merge pull request #12 from 3rd-Eden/err-409
409 Document Update Conflict
2 parents 98d4ccd + 358dfaa commit 20cf034

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

index.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -755,14 +755,14 @@ Mana.prototype.send = function send(args) {
755755

756756
if (
757757
!(res.statusCode >= 200 && res.statusCode < 300)
758-
&& 404 !== res.statusCode
758+
&& 404 !== res.statusCode && 409 !== res.statusCode
759759
) {
760760

761761
//
762762
// Assume that the server is returning an unknown response and that we
763763
// should try a different server.
764764
//
765-
mana.debug('Received an invalid statusCode (%s) for URL %s', res.statusCode, options.uri);
765+
mana.debug('Received an invalid statusCode (%s) for URL %s %s', res.statusCode, options.uri, body);
766766
err = new Error('Received a non 200 status code: '+ res.statusCode);
767767

768768
err.url = options.uri; // The URL we accessed.
@@ -819,17 +819,18 @@ Mana.prototype.send = function send(args) {
819819
// write it to our Assign instance it could cause issues as the data
820820
// format might differ. So instead we're going to call this as an error.
821821
//
822-
if (res.statusCode === 404 && 'HEAD' !== options.method) {
823-
err = new Error('Invalid status code: 404');
824-
825-
err.url = options.uri; // URL of the request.
826-
err.statusCode = 404; // Status code.
827-
err.errors = errors; // Previous errors.
828-
err.body = body; // The response body.
829-
err.data = data; // Parsed response.
830-
err.remaining = mana.remaining; // Rate remaining.
831-
err.ratereset = mana.ratereset; // Rate reset.
832-
err.ratelimit = mana.ratelimit; // Rate limit.
822+
if ((res.statusCode === 404 || res.statusCode === 409)
823+
&& 'HEAD' !== options.method) {
824+
err = new Error('Invalid status code: ' + res.statusCode);
825+
826+
err.url = options.uri; // URL of the request.
827+
err.statusCode = res.statusCode; // Status code.
828+
err.errors = errors; // Previous errors.
829+
err.body = body; // The response body.
830+
err.data = data; // Parsed response.
831+
err.remaining = mana.remaining; // Rate remaining.
832+
err.ratereset = mana.ratereset; // Rate reset.
833+
err.ratelimit = mana.ratelimit; // Rate limit.
833834

834835
return assign.destroy(err);
835836
}

0 commit comments

Comments
 (0)