소스 검색

TooManyRequestsException shouldn't actually throw an error

all other errors thrown here are network issues, this is not.
jomo 9 년 전
부모
커밋
a15cb20144
3개의 변경된 파일4개의 추가작업 그리고 8개의 파일을 삭제
  1. 1 5
      lib/networking.js
  2. 1 1
      lib/response.js
  3. 2 2
      test/test.js

+ 1 - 5
lib/networking.js

@@ -88,16 +88,12 @@ exp.get_from_options = function(rid, url, options, callback) {
         break;
         break;
       case 404:
       case 404:
       case 204:
       case 204:
+      case 429: // this shouldn't usually happen, but occasionally does
       case 500:
       case 500:
       case 503:
       case 503:
         // we don't want to cache this
         // we don't want to cache this
         body = null;
         body = null;
         break;
         break;
-      case 429:
-        // this shouldn't usually happen, but occasionally does
-        // forcing error so it's not cached
-        error = error || new Error("TooManyRequestsException");
-        break;
       default:
       default:
         if (!error) {
         if (!error) {
           // Probably 500 or the likes
           // Probably 500 or the likes

+ 1 - 1
lib/response.js

@@ -13,7 +13,7 @@ var human_status = {
 
 
 
 
 // print these, but without stacktrace
 // print these, but without stacktrace
-var silent_errors = ["ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNRESET", "EHOSTUNREACH", "ECONNREFUSED", "TooManyRequestsException"];
+var silent_errors = ["ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNRESET", "EHOSTUNREACH", "ECONNREFUSED"];
 
 
 // handles HTTP responses
 // handles HTTP responses
 // +request+ a http.IncomingMessage
 // +request+ a http.IncomingMessage

+ 2 - 2
test/test.js

@@ -1013,8 +1013,8 @@ describe("Crafatar", function() {
           it("uuid should be rate limited", function(done) {
           it("uuid should be rate limited", function(done) {
             networking.get_profile(rid, id, function() {
             networking.get_profile(rid, id, function() {
               networking.get_profile(rid, id, function(err, profile) {
               networking.get_profile(rid, id, function(err, profile) {
-                assert.strictEqual(err.message, "TooManyRequestsException");
-                assert.strictEqual(profile.error, "TooManyRequestsException");
+                assert.ifError(err);
+                assert.strictEqual(profile, null);
                 done();
                 done();
               });
               });
             });
             });