New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@golemio/errors

Package Overview
Dependencies
Maintainers
4
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@golemio/errors - npm Package Compare versions

Comparing version 0.0.7-dev.217738887 to 1.0.0-dev.217893967

4

dist/CustomError.d.ts

@@ -51,2 +51,6 @@ /**

toObject: () => ICustomErrorObject;
/**
* Converts cause (Error or CustomError) object to string
*/
private causeToString;
}

@@ -31,3 +31,3 @@ "use strict";

+ this.message
+ ((this.cause) ? ` (${(this.cause.toString() || this.cause.message)})` : ``)
+ ((this.cause) ? ` (${this.causeToString(this.cause)})` : ``)
+ ((process.env.NODE_ENV === "development") ? `\n ${this.stack}` : ``);

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

if (this.cause) {
toReturn.error_info = this.cause.toString() || this.cause.message;
toReturn.error_info = this.causeToString(this.cause);
}

@@ -65,4 +65,17 @@ if (process.env.NODE_ENV === "development") {

}
/**
* Converts cause (Error or CustomError) object to string
*/
causeToString(cause) {
let info = null;
try {
info = JSON.stringify(this.cause);
}
catch (_a) {
info = cause.message;
}
return (info === "{}") ? cause.message : info;
}
}
exports.CustomError = CustomError;
//# sourceMappingURL=CustomError.js.map

9

dist/ErrorHandler.d.ts
import { CustomError, ICustomErrorObject } from "./";
import { LogLevels } from "./Logger";
import { ILogger, LogLevels } from "./Logger";
/**

@@ -15,7 +15,8 @@ * Class responsible for error handling in the app. Catches errors and based on their type performs some action.

*
* @param err Error (CustomError) object to catch and process
* @param logLevel LogLevels log level method
* @param {Error|CustomError} err object to catch and process
* @param {LogLevels} logLevel log level method, default "error"
* @param {ILogger} logger logger function, default internal Logger
* @returns ICustomErrorObject
*/
static handle(err: Error | CustomError, logLevel?: LogLevels): ICustomErrorObject;
static handle(err: Error | CustomError, logLevel?: LogLevels, logger?: ILogger): ICustomErrorObject;
}

@@ -18,14 +18,15 @@ "use strict";

*
* @param err Error (CustomError) object to catch and process
* @param logLevel LogLevels log level method
* @param {Error|CustomError} err object to catch and process
* @param {LogLevels} logLevel log level method, default "error"
* @param {ILogger} logger logger function, default internal Logger
* @returns ICustomErrorObject
*/
static handle(err, logLevel = "error") {
static handle(err, logLevel = "error", logger = Logger_1.log) {
if (err instanceof _1.CustomError && err.isOperational) {
// log level for operational error is set dynamically, default level is `error`
Logger_1.log[logLevel](err.toString());
logger[logLevel](err);
return err.toObject();
}
else { // Unexpected non-operational error, handle it!
Logger_1.log.error(err.toString());
logger.error(err.toString());
// if anything fails, process is killed

@@ -32,0 +33,0 @@ return process.exit((err instanceof _1.CustomError && err.code) ? err.code : 1);

import { CustomError, ErrorHandler, ICustomErrorObject } from "./";
import { LogLevels } from "./Logger";
import { ILogger, LogLevels } from "./Logger";
/**

@@ -15,7 +15,8 @@ * Class responsible for error handling in the app. Catches errors and based on their type performs some action.

*
* @param err Error (CustomError) object to catch and process
* @param logLevel LogLevels log level method
* @param {Error|CustomError} err object to catch and process
* @param {LogLevels} logLevel log level method, default "error"
* @param {ILogger} logger logger function, default internal Logger
* @returns ICustomErrorObject
*/
static handle(err: Error | CustomError, logLevel?: LogLevels): ICustomErrorObject;
static handle(err: Error | CustomError, logLevel?: LogLevels, logger?: ILogger): ICustomErrorObject;
}

@@ -5,2 +5,3 @@ "use strict";

const _1 = require("./");
const Logger_1 = require("./Logger");
/**

@@ -18,9 +19,10 @@ * Class responsible for error handling in the app. Catches errors and based on their type performs some action.

*
* @param err Error (CustomError) object to catch and process
* @param logLevel LogLevels log level method
* @param {Error|CustomError} err object to catch and process
* @param {LogLevels} logLevel log level method, default "error"
* @param {ILogger} logger logger function, default internal Logger
* @returns ICustomErrorObject
*/
static handle(err, logLevel = "error") {
static handle(err, logLevel = "error", logger = Logger_1.log) {
// Call super to handle non-operational error
const errObject = super.handle(err, logLevel);
const errObject = super.handle(err, logLevel, logger);
let toReturn;

@@ -27,0 +29,0 @@ // Define what to return to user

import * as winston from "winston";
export declare type LogLevels = "error" | "warn" | "info" | "debug" | "silly";
interface ILogger {
export interface ILogger {
error: winston.LeveledLogMethod;

@@ -5,0 +5,0 @@ warn: winston.LeveledLogMethod;

{
"name": "@golemio/errors",
"version": "0.0.7-dev.217738887",
"version": "1.0.0-dev.217893967",
"description": "Library of Error classes of the Golemio Data Platform System",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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

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