@venncity/errors
Advanced tools
Comparing version 1.7.15 to 1.7.16-addSentry.32
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const errorHandler_1 = require("./errorHandler"); | ||
describe('errorHandler', () => { | ||
test('Should format correctly for service', () => { | ||
test('Should format correctly for service', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const testData = { originalError: { message: 'VennUnknownError', code: 'VennUnknownError' } }; | ||
@@ -15,3 +24,3 @@ const response = errorHandler_1.defaultServiceErrorFormatter(testData); | ||
}); | ||
}); | ||
})); | ||
test('Should format correctly for gateway', () => { | ||
@@ -18,0 +27,0 @@ const testData = { |
@@ -1,2 +0,2 @@ | ||
export declare function handleErrorThrown(e: any): any; | ||
export declare function handleErrorThrown(e: any): Body; | ||
declare type Body = { | ||
@@ -3,0 +3,0 @@ traceId: string; |
@@ -6,2 +6,3 @@ "use strict"; | ||
const errors_1 = require("../errors/errors"); | ||
const sentry_1 = require("../errorReporting/sentry"); | ||
const config = require('@venncity/nested-config')(__dirname); | ||
@@ -17,3 +18,5 @@ const { VENN_ERROR, VENN_UNKNOWN_ERROR } = errors_1.codes; | ||
console[logLevel](e, `traceId=${e.traceId}`); | ||
return errorResponse(e); | ||
const errorToThrow = errorResponse(e); | ||
sentry_1.reportErrorToSentry(e, { level: logLevel, tags: { traceId: e.traceId }, contexts: { errorThrown: errorToThrow } }); | ||
return errorToThrow; | ||
} | ||
@@ -20,0 +23,0 @@ exports.handleErrorThrown = handleErrorThrown; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -24,3 +33,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}); | ||
test('Should format error correctly', () => { | ||
test('Should format error correctly', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const data = formatError_1.handleErrorThrown(errorJSON); | ||
@@ -35,4 +44,4 @@ expect(data).toMatchObject({ | ||
sinon_1.default.assert.calledWith(consoleSpy, errorJSON); | ||
}); | ||
test('Should format vennError thrown with clientVisible:true correctly', () => { | ||
})); | ||
test('Should format vennError thrown with clientVisible:true correctly', () => __awaiter(void 0, void 0, void 0, function* () { | ||
let errorThrown; | ||
@@ -65,4 +74,4 @@ try { | ||
})); | ||
}); | ||
test('Should format vennError thrown with clientVisible:false correctly', () => { | ||
})); | ||
test('Should format vennError thrown with clientVisible:false correctly', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const data = formatError_1.handleErrorThrown(vennErrorWithClientVisibleFalse); | ||
@@ -75,3 +84,3 @@ expect(data).toMatchObject({ | ||
sinon_1.default.assert.calledWith(consoleSpy, vennErrorWithClientVisibleFalse); | ||
}); | ||
})); | ||
}); | ||
@@ -78,0 +87,0 @@ /* eslint-disable */ |
@@ -5,2 +5,3 @@ import * as errors from './errors/errors'; | ||
import * as errorHandler from './errorHandler/errorHandler'; | ||
export { errors, validator, errorFormatter, errorHandler }; | ||
import * as errorReporting from './errorReporting/sentry'; | ||
export { errors, validator, errorFormatter, errorHandler, errorReporting }; |
@@ -22,3 +22,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.errorHandler = exports.errorFormatter = exports.validator = exports.errors = void 0; | ||
exports.errorReporting = exports.errorHandler = exports.errorFormatter = exports.validator = exports.errors = void 0; | ||
const errors = __importStar(require("./errors/errors")); | ||
@@ -32,2 +32,4 @@ exports.errors = errors; | ||
exports.errorHandler = errorHandler; | ||
const errorReporting = __importStar(require("./errorReporting/sentry")); | ||
exports.errorReporting = errorReporting; | ||
//# sourceMappingURL=index.js.map |
@@ -0,4 +1,13 @@ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
import { defaultServiceErrorFormatter, defaultGatewayErrorFormatter } from './errorHandler'; | ||
describe('errorHandler', () => { | ||
test('Should format correctly for service', () => { | ||
test('Should format correctly for service', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const testData = { originalError: { message: 'VennUnknownError', code: 'VennUnknownError' } }; | ||
@@ -13,3 +22,3 @@ const response = defaultServiceErrorFormatter(testData); | ||
}); | ||
}); | ||
})); | ||
test('Should format correctly for gateway', () => { | ||
@@ -16,0 +25,0 @@ const testData = { |
@@ -1,2 +0,2 @@ | ||
export declare function handleErrorThrown(e: any): any; | ||
export declare function handleErrorThrown(e: any): Body; | ||
declare type Body = { | ||
@@ -3,0 +3,0 @@ traceId: string; |
import { v4 as uuidv4 } from 'uuid'; | ||
import { VError, codes, SUPPORTED_LOG_LEVELS } from '../errors/errors'; | ||
import { reportErrorToSentry } from '../errorReporting/sentry'; | ||
const config = require('@venncity/nested-config')(__dirname); | ||
@@ -13,3 +14,5 @@ const { VENN_ERROR, VENN_UNKNOWN_ERROR } = codes; | ||
console[logLevel](e, `traceId=${e.traceId}`); | ||
return errorResponse(e); | ||
const errorToThrow = errorResponse(e); | ||
reportErrorToSentry(e, { level: logLevel, tags: { traceId: e.traceId }, contexts: { errorThrown: errorToThrow } }); | ||
return errorToThrow; | ||
} | ||
@@ -16,0 +19,0 @@ function getLogLevelFromError(e) { |
@@ -0,1 +1,10 @@ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
import sinon from 'sinon'; | ||
@@ -19,3 +28,3 @@ import { VennError } from '../errors/errors'; | ||
}); | ||
test('Should format error correctly', () => { | ||
test('Should format error correctly', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const data = handleErrorThrown(errorJSON); | ||
@@ -30,4 +39,4 @@ expect(data).toMatchObject({ | ||
sinon.assert.calledWith(consoleSpy, errorJSON); | ||
}); | ||
test('Should format vennError thrown with clientVisible:true correctly', () => { | ||
})); | ||
test('Should format vennError thrown with clientVisible:true correctly', () => __awaiter(void 0, void 0, void 0, function* () { | ||
let errorThrown; | ||
@@ -60,4 +69,4 @@ try { | ||
})); | ||
}); | ||
test('Should format vennError thrown with clientVisible:false correctly', () => { | ||
})); | ||
test('Should format vennError thrown with clientVisible:false correctly', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const data = handleErrorThrown(vennErrorWithClientVisibleFalse); | ||
@@ -70,3 +79,3 @@ expect(data).toMatchObject({ | ||
sinon.assert.calledWith(consoleSpy, vennErrorWithClientVisibleFalse); | ||
}); | ||
})); | ||
}); | ||
@@ -73,0 +82,0 @@ /* eslint-disable */ |
@@ -5,2 +5,3 @@ import * as errors from './errors/errors'; | ||
import * as errorHandler from './errorHandler/errorHandler'; | ||
export { errors, validator, errorFormatter, errorHandler }; | ||
import * as errorReporting from './errorReporting/sentry'; | ||
export { errors, validator, errorFormatter, errorHandler, errorReporting }; |
@@ -5,3 +5,4 @@ import * as errors from './errors/errors'; | ||
import * as errorHandler from './errorHandler/errorHandler'; | ||
export { errors, validator, errorFormatter, errorHandler }; | ||
import * as errorReporting from './errorReporting/sentry'; | ||
export { errors, validator, errorFormatter, errorHandler, errorReporting }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@venncity/errors", | ||
"version": "1.7.15", | ||
"version": "1.7.16-addSentry.32+75257c77b", | ||
"author": "Venn Engineering", | ||
@@ -21,3 +21,3 @@ "main": "lib/cjs/index.js", | ||
"@venncity/eslint-config": "^3.0.1", | ||
"@venncity/jest-config-server": "^3.3.4", | ||
"@venncity/jest-config-server": "^3.4.0", | ||
"eslint": "^5.5.0", | ||
@@ -35,3 +35,5 @@ "eslint-config-airbnb-base": "^13.1.0", | ||
"dependencies": { | ||
"@venncity/nested-config": "^2.0.23", | ||
"@sentry/node": "^5.21.1", | ||
"@sentry/types": "^5.21.1", | ||
"@venncity/nested-config": "^2.0.24-addSentry.32+75257c77b", | ||
"fast-safe-stringify": "^2.0.7", | ||
@@ -43,3 +45,3 @@ "joi": "^14.3.1", | ||
}, | ||
"gitHead": "3bbedc3a997f1971dd59af01468105473fa84f2f" | ||
"gitHead": "75257c77b902c481ba014fd57b22bc71f92aebca" | ||
} |
import { defaultServiceErrorFormatter, defaultGatewayErrorFormatter } from './errorHandler'; | ||
describe('errorHandler', () => { | ||
test('Should format correctly for service', () => { | ||
test('Should format correctly for service', async () => { | ||
const testData = { originalError: { message: 'VennUnknownError', code: 'VennUnknownError' } }; | ||
@@ -6,0 +6,0 @@ const response = defaultServiceErrorFormatter(testData); |
@@ -26,3 +26,3 @@ import sinon, { SinonStub } from 'sinon'; | ||
test('Should format error correctly', () => { | ||
test('Should format error correctly', async () => { | ||
const data = handleErrorThrown(errorJSON); | ||
@@ -40,3 +40,3 @@ expect(data).toMatchObject({ | ||
test('Should format vennError thrown with clientVisible:true correctly', () => { | ||
test('Should format vennError thrown with clientVisible:true correctly', async () => { | ||
let errorThrown: any; | ||
@@ -75,3 +75,3 @@ try { | ||
test('Should format vennError thrown with clientVisible:false correctly', () => { | ||
test('Should format vennError thrown with clientVisible:false correctly', async () => { | ||
const data = handleErrorThrown(vennErrorWithClientVisibleFalse); | ||
@@ -78,0 +78,0 @@ expect(data).toMatchObject({ |
import { v4 as uuidv4 } from 'uuid'; | ||
import { VError, codes, SUPPORTED_LOG_LEVELS } from '../errors/errors'; | ||
import { reportErrorToSentry } from '../errorReporting/sentry'; | ||
@@ -9,3 +10,3 @@ const config = require('@venncity/nested-config')(__dirname); | ||
export function handleErrorThrown(e: any) { | ||
export function handleErrorThrown(e: any): Body { | ||
if (config.has('service.exposeErrors') && config.get('service.exposeErrors')) { | ||
@@ -18,3 +19,5 @@ return e; | ||
console[logLevel](e, `traceId=${e.traceId}`); | ||
return errorResponse(e); | ||
const errorToThrow = errorResponse(e); | ||
reportErrorToSentry(e, { level: logLevel, tags: { traceId: e.traceId }, contexts: { errorThrown: errorToThrow } }); | ||
return errorToThrow; | ||
} | ||
@@ -21,0 +24,0 @@ function getLogLevelFromError(e) { |
@@ -5,4 +5,5 @@ import * as errors from './errors/errors'; | ||
import * as errorHandler from './errorHandler/errorHandler'; | ||
import * as errorReporting from './errorReporting/sentry'; | ||
export { errors, validator, errorFormatter, errorHandler }; | ||
export { errors, validator, errorFormatter, errorHandler, errorReporting }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
138845
77
2150
8
2
15
1
+ Added@sentry/node@^5.21.1
+ Added@sentry/types@^5.21.1
+ Added@sentry/core@5.30.0(transitive)
+ Added@sentry/hub@5.30.0(transitive)
+ Added@sentry/minimal@5.30.0(transitive)
+ Added@sentry/node@5.30.0(transitive)
+ Added@sentry/tracing@5.30.0(transitive)
+ Added@sentry/utils@5.30.0(transitive)
Updated@venncity/nested-config@^2.0.24-addSentry.32+75257c77b