Skip to content

Commit

Permalink
Fix error is ignored.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kentzo committed Jan 10, 2013
1 parent ea71d43 commit 1346043
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions WLRemoteLink.j
Expand Up @@ -725,7 +725,6 @@ var WLRemoteActionSerial = 1;

result = nil;
error = [self statusCode];
error = error >= 200 && error <= 299 ? nil : error; // 2XX codes are not errors.

if (error === 0)
{
Expand All @@ -734,23 +733,28 @@ var WLRemoteActionSerial = 1;
error = [aConnection _HTTPRequest].success() ? 200 : 503;
}

// If the status code says there should be no data, expect no data.
if ([self statusCode] == 204)
{
if (data && data !== "OK")
CPLog.warn("Unexpected data in response: %@", data);
}
else
error = error >= 200 && error <= 299 ? nil : error; // 2XX codes are not errors.

if (!error)
{
// Ok there's data.
try
// If the status code says there should be no data, expect no data.
if ([self statusCode] == 204)
{
result = [self decodeResponseBody:data];
if (data && data !== "OK")
CPLog.warn("Unexpected data in response: %@", data);
}
catch(err)
else
{
CPLog.error("Unable to decode response (status code %d).", [self statusCode]);
error = 500;
// Ok there's data.
try
{
result = [self decodeResponseBody:data];
}
catch(err)
{
CPLog.error("Unable to decode response (status code %d).", [self statusCode]);
error = 500;
}
}
}

Expand Down

0 comments on commit 1346043

Please sign in to comment.