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

bloody-simple-s3

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bloody-simple-s3 - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

src/CustomError.js

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 0.5.0 - 2015-05-25
* Introduce custom errors with distinct names for better visibility
## 0.4.0 - 2015-05-15

@@ -2,0 +6,0 @@

8

package.json
{
"name": "bloody-simple-s3",
"version": "0.4.0",
"version": "0.5.0",
"description": "A bloody simple interface to S3, based on the official AWS sdk",

@@ -23,3 +23,7 @@ "repository": {

],
"author": "Dimitrios C. Michalakos <dimitris@jmike.gr>",
"author": {
"name": "Dimitrios C. Michalakos",
"email": "dimitris@jmike.gr",
"url": "https://github.com/jmike"
},
"license": "MIT",

@@ -26,0 +30,0 @@ "dependencies": {

@@ -13,5 +13,7 @@ var path = require('path');

var CustomError = require('./CustomError');
function BloodySimpleS3(options) {
if (!_.isPlainObject(options)) {
throw new Error('Invalid options param; expected object, received ' + type(options));
throw new CustomError('Invalid options param; expected object, received ' + type(options), 'InvalidArgument');
}

@@ -25,19 +27,19 @@

if (!_.isString(options.bucket)) {
throw new Error('Invalid bucket option; expected string, received ' + type(options.bucket));
throw new CustomError('Invalid bucket option; expected string, received ' + type(options.bucket), 'InvalidArgument');
}
if (!_.isString(options.accessKeyId)) {
throw new Error('Invalid accessKeyId option; expected string, received ' + type(options.accessKeyId));
throw new CustomError('Invalid accessKeyId option; expected string, received ' + type(options.accessKeyId), 'InvalidArgument');
}
if (!_.isString(options.secretAccessKey)) {
throw new Error('Invalid secretAccessKey option; expected string, received ' + type(options.secretAccessKey));
throw new CustomError('Invalid secretAccessKey option; expected string, received ' + type(options.secretAccessKey), 'InvalidArgument');
}
if (!_.isString(options.region)) {
throw new Error('Invalid region option; expected string, received ' + type(options.region));
throw new CustomError('Invalid region option; expected string, received ' + type(options.region), 'InvalidArgument');
}
if (!_.isBoolean(options.sslEnabled)) {
throw new Error('Invalid sslEnabled option; expected boolean, received ' + type(options.sslEnabled));
throw new CustomError('Invalid sslEnabled option; expected boolean, received ' + type(options.sslEnabled), 'InvalidArgument');
}

@@ -60,3 +62,3 @@

if (!_.isString(filename)) {
throw new Error('Invalid filename param; expected string, received ' + type(filename));
throw new CustomError('Invalid filename param; expected string, received ' + type(filename), 'InvalidArgument');
}

@@ -77,3 +79,3 @@

if (!_.isString(source)) {
return Promise.reject(new Error('Invalid source param; expected string, received ' + type(source)))
return Promise.reject(new CustomError('Invalid source param; expected string, received ' + type(source)), 'InvalidArgument')
.nodeify(callback);

@@ -90,3 +92,3 @@ }

if (!_.isString(target)) {
return Promise.reject(new Error('Invalid target param; expected string, received ' + type(target)))
return Promise.reject(new CustomError('Invalid target param; expected string, received ' + type(target)), 'InvalidArgument')
.nodeify(callback);

@@ -108,3 +110,3 @@ }

} else {
return reject(new Error('Invalid target path; expected directory or file'));
return reject(new CustomError('Invalid target path; expected directory or file', 'InvalidDownloadTarget'));
}

@@ -135,10 +137,5 @@

.then(function (buf) {
var err;
if (props.meta.ETag !== '"' + crypto.createHash('md5').update(buf).digest().toString('hex') + '"') {
err = new Error('Bad MD5 digest for file ' + source);
err.code = 'BAD_DIGEST';
return fs.unlinkAsync(props.file.name) // remove downloaded file from disk
.throw(err);
.throw(new CustomError('Invalid checksum of file ' + source, 'BadMD5Digest'));
}

@@ -181,3 +178,3 @@

if (!_.isString(filename)) {
return Promise.reject(new Error('Invalid filename param; expected string, received ' + type(filename)))
return Promise.reject(new CustomError('Invalid filename param; expected string, received ' + type(filename)), 'InvalidArgument')
.nodeify(callback);

@@ -187,3 +184,3 @@ }

if (!(contents instanceof stream.Readable) && !(Buffer.isBuffer(contents)) && !_.isString(contents)) {
return Promise.reject(new Error('Invalid contents param; expected readable stream, buffer or string, received ' + type(contents)))
return Promise.reject(new CustomError('Invalid contents param; expected readable stream, buffer or string, received ' + type(contents)), 'InvalidArgument')
.nodeify(callback);

@@ -217,3 +214,3 @@ }

if (!_.isString(source)) {
return Promise.reject(new Error('Invalid source param; expected string, received ' + type(source)))
return Promise.reject(new CustomError('Invalid source param; expected string, received ' + type(source)), 'InvalidArgument')
.nodeify(callback);

@@ -232,3 +229,3 @@ }

if (!_.isString(target)) {
return Promise.reject(new Error('Invalid target param; expected string, received ' + type(target)))
return Promise.reject(new CustomError('Invalid target param; expected string, received ' + type(target)), 'InvalidArgument')
.nodeify(callback);

@@ -239,8 +236,4 @@ }

.then(function (stats) {
var err;
if (!stats.isFile()) {
err = new Error('Source is invalid; you must reference a file');
err.code = 'INVALID_SOURCE';
throw err;
throw new CustomError('Source is invalid; you must reference a file', 'InvalidUploadSource');
}

@@ -266,3 +259,3 @@

if (!_.isString(dir)) {
return Promise.reject(new Error('Invalid dir param; expected string, received ' + type(dir)))
return Promise.reject(new CustomError('Invalid dir param; expected string, received ' + type(dir)), 'InvalidArgument')
.nodeify(callback);

@@ -279,3 +272,3 @@ }

if (!_.isPlainObject(options)) {
return Promise.reject(new Error('Invalid options param; expected object, received ' + type(options)))
return Promise.reject(new CustomError('Invalid options param; expected object, received ' + type(options)), 'InvalidArgument')
.nodeify(callback);

@@ -318,3 +311,3 @@ }

if (!_.isString(source)) {
return Promise.reject(new Error('Invalid source param; expected string, received ' + type(source)))
return Promise.reject(new CustomError('Invalid source param; expected string, received ' + type(source)), 'InvalidArgument')
.nodeify(callback);

@@ -324,3 +317,3 @@ }

if (!_.isString(target)) {
return Promise.reject(new Error('Invalid target param; expected string, received ' + type(target)))
return Promise.reject(new CustomError('Invalid target param; expected string, received ' + type(target)), 'InvalidArgument')
.nodeify(callback);

@@ -337,3 +330,3 @@ }

if (!_.isPlainObject(options)) {
return Promise.reject(new Error('Invalid options param; expected object, received ' + type(options)))
return Promise.reject(new CustomError('Invalid options param; expected object, received ' + type(options)), 'InvalidArgument')
.nodeify(callback);

@@ -365,3 +358,3 @@ }

if (!_.isString(filename)) {
return Promise.reject(new Error('Invalid filename param; expected string, received ' + type(filename)))
return Promise.reject(new CustomError('Invalid filename param; expected string, received ' + type(filename)), 'InvalidArgument')
.nodeify(callback);

@@ -407,3 +400,3 @@ }

if (!_.isString(filename)) {
throw new Error('Invalid filename param; expected string, received ' + type(filename));
throw new CustomError('Invalid filename param; expected string, received ' + type(filename), 'InvalidArgument');
}

@@ -410,0 +403,0 @@

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