@venncity/errors
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [1.5.0](https://github.com/venn-city/npm-shelf/compare/@venncity/errors@1.4.1...@venncity/errors@1.5.0) (2019-11-19) | ||
### Features | ||
* add clientVisible to ForbiddenError ([fb71c68](https://github.com/venn-city/npm-shelf/commit/fb71c68)) | ||
* add token expired error ([6cc0afd](https://github.com/venn-city/npm-shelf/commit/6cc0afd)) | ||
## [1.4.1](https://github.com/venn-city/npm-shelf/compare/@venncity/errors@1.4.0...@venncity/errors@1.4.1) (2019-10-24) | ||
@@ -8,0 +20,0 @@ |
{ | ||
"name": "@venncity/errors", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"author": "Venn Engineering", | ||
@@ -29,3 +29,3 @@ "main": "src/index.js", | ||
}, | ||
"gitHead": "b0a79280047ee179906117673f0195764a78009c" | ||
"gitHead": "ca8b0714a5b9f1358b766af8f17386b9c2da26e7" | ||
} |
@@ -6,2 +6,3 @@ const { VError } = require('verror'); | ||
const VENN_FORBIDDEN_ERROR = 'VennForbiddenError'; | ||
const VENN_TOKEN_EXPIRED_ERROR = 'VennTokenExpired'; | ||
const VENN_THROTTLING_ERROR = 'VennThrottlingError'; | ||
@@ -16,13 +17,22 @@ const VENN_SERVER_DATA_VALIDATION_ERROR = 'VennServerDataValidationError'; | ||
class VennError extends VError { | ||
constructor({ cause, message, clientVisible = false, statusCode = 500, name = VENN_ERROR, logLevel = SUPPORTED_LOG_LEVELS.ERROR }) { | ||
super({ | ||
name, | ||
cause, | ||
info: { | ||
clientVisible, | ||
statusCode | ||
} | ||
}, message); | ||
constructor({ | ||
cause, | ||
message, | ||
clientVisible = false, | ||
statusCode = 500, | ||
name = VENN_ERROR, | ||
logLevel = SUPPORTED_LOG_LEVELS.ERROR | ||
}) { | ||
super( | ||
{ | ||
name, | ||
cause, | ||
info: { | ||
clientVisible, | ||
statusCode | ||
} | ||
}, | ||
message | ||
); | ||
this.isVennError = true; | ||
@@ -35,3 +45,10 @@ this.logLevel = logLevel; | ||
constructor({ cause, message, clientVisible, logLevel }) { | ||
super({ cause, message, clientVisible, statusCode: 429, name: VENN_THROTTLING_ERROR, logLevel }); | ||
super({ | ||
cause, | ||
message, | ||
clientVisible, | ||
statusCode: 429, | ||
name: VENN_THROTTLING_ERROR, | ||
logLevel | ||
}); | ||
} | ||
@@ -49,3 +66,10 @@ } | ||
constructor({ cause, message, clientVisible = false, logLevel }) { | ||
super({ cause, message, clientVisible, statusCode: 500, name: VENN_SERVER_DATA_VALIDATION_ERROR, logLevel }); | ||
super({ | ||
cause, | ||
message, | ||
clientVisible, | ||
statusCode: 500, | ||
name: VENN_SERVER_DATA_VALIDATION_ERROR, | ||
logLevel | ||
}); | ||
} | ||
@@ -56,3 +80,10 @@ } | ||
constructor({ cause, message, clientVisible = true, logLevel }) { | ||
super({ cause, message, clientVisible, statusCode: 400, name: VENN_CLIENT_DATA_VALIDATION_ERROR, logLevel }); | ||
super({ | ||
cause, | ||
message, | ||
clientVisible, | ||
statusCode: 400, | ||
name: VENN_CLIENT_DATA_VALIDATION_ERROR, | ||
logLevel | ||
}); | ||
} | ||
@@ -73,2 +104,15 @@ } | ||
class TokenExpiredError extends VennError { | ||
constructor({ cause, logLevel = SUPPORTED_LOG_LEVELS.INFO }) { | ||
super({ | ||
name: VENN_TOKEN_EXPIRED_ERROR, | ||
message: 'TokenExpiredError', | ||
cause, | ||
clientVisible: true, | ||
statusCode: 401, | ||
logLevel | ||
}); | ||
} | ||
} | ||
class UnknownError extends VennError { | ||
@@ -90,2 +134,3 @@ constructor(cause) { | ||
ThrottlingError, | ||
TokenExpiredError, | ||
VennError, | ||
@@ -92,0 +137,0 @@ VError, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12772
289