Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

disconnect

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

disconnect - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

lib/error.js

5

HISTORY.md

@@ -0,1 +1,6 @@

0.2.1 / 2014-06-20
==================
* Fixed data encoding bug for gzipped response from `0.2.0`
* First implementation of generic error handling using custom `Error` objects containing the HTTP status code
0.2.0 / 2014-06-19

@@ -2,0 +7,0 @@ ==================

26

lib/client.js

@@ -6,3 +6,4 @@ var http = require('http'),

OAuth = require('oauth-1.0a'),
package = require('../package.json');
package = require('../package.json'),
error = require('./error.js');

@@ -138,3 +139,3 @@ module.exports = DiscogsClient;

}else{
callback(new Error('You must be authenticated in order to view the identity resource.'));
callback(new error.AuthError());
}

@@ -160,3 +161,3 @@ };

oauth = options.oauth||this.oauth,
encoding = options.encoding||'utf8';
encoding = options.encoding||null;

@@ -201,8 +202,19 @@ // Build request headers

rateLimit = null,
add = function(chunk){ data += chunk.toString(); },
passData = function(){ (typeof callback === 'function')&&callback(null, data, rateLimit); };
add = function(chunk){ data += chunk.toString(); };
// Set encoding
res.setEncoding(encoding);
// Pass the data to the callback and pass an error on unsuccessful HTTP status
var passData = function(){
if(typeof callback === 'function'){
var err = null, status = parseInt(res.statusCode, 10);
if(status > 399){ // Unsuccessful HTTP status? Then pass an error to the callback
var match = data.match(/^\{"message": "(.+)"\}/i);
err = new error.DiscogsError(status, ((match&&match[1]) ? match[1] : null));
}
callback(err, data, rateLimit);
}
};
// Set encoding when provided
encoding&&res.setEncoding(encoding);
// Find and add rate limiting when present

@@ -209,0 +221,0 @@ if(res.headers['x-ratelimit-type']){

@@ -1,2 +0,3 @@

var util = require('./util.js');
var util = require('./util.js'),
AuthError = require('./error.js').AuthError;

@@ -34,3 +35,3 @@ module.exports = function(client){

}else{
callback(new Error('You must be authenticated as the owner in order to add a new folder.'));
callback(new AuthError());
}

@@ -51,3 +52,3 @@ };

}else{
callback(new Error('You must be authenticated as the owner in order to edit a folder name.'));
callback(new AuthError());
}

@@ -67,3 +68,3 @@ };

}else{
callback(new Error('You must be authenticated as the owner in order to delete a folder.'));
callback(new AuthError());
}

@@ -91,3 +92,3 @@ };

}else{
callback(new Error('You must be authenticated in order to view the releases in this folder.'));
callback(new AuthError());
}

@@ -109,3 +110,3 @@ };

}else{
callback(new Error('You must be authenticated in order to add a release to a folder.'));
callback(new AuthError());
}

@@ -128,3 +129,3 @@ };

}else{
callback(new Error('You must be authenticated in order to edit a release instance.'));
callback(new AuthError());
}

@@ -146,3 +147,3 @@ };

}else{
callback(new Error('You must be authenticated in order to delete a release instance.'));
callback(new AuthError());
}

@@ -149,0 +150,0 @@ };

@@ -1,2 +0,3 @@

var util = require('./util.js');
var util = require('./util.js'),
authError = require('./error.js').AuthError;

@@ -96,3 +97,3 @@ module.exports = function(client){

}else{
callback(new Error('You must be authenticated in order to retrieve an image.'));
callback(new authError());
}

@@ -99,0 +100,0 @@ };

@@ -1,2 +0,3 @@

var util = require('./util.js');
var util = require('./util.js'),
AuthError = require('./error.js').AuthError;

@@ -33,3 +34,3 @@ module.exports = function(client){

}else{
callback(new Error('You must be authenticated in order to create a marketplace listing.'));
callback(new AuthError());
}

@@ -49,3 +50,3 @@ };

}else{
callback(new Error('You must be authenticated in order to edit a marketplace listing.'));
callback(new AuthError());
}

@@ -64,3 +65,3 @@ };

}else{
callback(new Error('You must be authenticated in order to delete a marketplace listing.'));
callback(new AuthError());
}

@@ -90,3 +91,3 @@ };

}else{
callback(new Error('You must be authenticated in order to view your orders.'));
callback(new AuthError());
}

@@ -107,3 +108,3 @@ };

}else{
callback(new Error('You must be authenticated in order to edit an order.'));
callback(new AuthError());
}

@@ -129,3 +130,3 @@ };

}else{
callback(new Error('You must be authenticated in order to view order messages.'));
callback(new AuthError());
}

@@ -145,3 +146,3 @@ };

}else{
callback(new Error('You must be authenticated in order to add an order message.'));
callback(new AuthError());
}

@@ -177,3 +178,3 @@ };

}else{
callback(new Error('You must be authenticated in order to get a price suggestion.'));
callback(new AuthError());
}

@@ -180,0 +181,0 @@ };

@@ -0,1 +1,4 @@

var util = require('./util.js'),
AuthError = require('./error.js').AuthError;
module.exports = function(client){

@@ -38,3 +41,3 @@ var wantlist = {};

}else{
callback(new Error('You must be authenticated in order to add a release to a wantlist.'));
callback(new AuthError());
}

@@ -55,3 +58,3 @@ };

}else{
callback(new Error('You must be authenticated in order to edit the notes for a release in a wantlist.'));
callback(new AuthError());
}

@@ -71,3 +74,3 @@ };

}else{
callback(new Error('You must be authenticated in order to delete a release from a wantlist.'));
callback(new AuthError());
}

@@ -74,0 +77,0 @@ };

{
"name": "disconnect",
"description": "Easy to use client to connect with the discogs.com API v2.0",
"version": "0.2.0",
"version": "0.2.1",
"keywords": ["discogs", "api", "client", "oauth"],

@@ -6,0 +6,0 @@ "homepage": "https://github.com/bartve/disconnect",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc