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

@augment-vir/common

Package Overview
Dependencies
Maintainers
1
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@augment-vir/common - npm Package Compare versions

Comparing version 14.3.1 to 14.4.0

29

dist/cjs/augments/error.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeAndReturnError = exports.wrapInTry = exports.ensureError = exports.extractErrorMessage = exports.combineErrorMessages = exports.combineErrors = void 0;
exports.executeAndReturnError = exports.wrapInTry = exports.ensureErrorAndPrependMessage = exports.ensureError = exports.extractErrorMessage = exports.combineErrorMessages = exports.combineErrors = void 0;
const __1 = require("..");

@@ -23,23 +23,32 @@ function combineErrors(errors) {

exports.combineErrorMessages = combineErrorMessages;
function extractErrorMessage(error) {
if (!error) {
function extractErrorMessage(maybeError) {
if (!maybeError) {
return '';
}
if (error instanceof Error) {
return error.message;
if (maybeError instanceof Error) {
return maybeError.message;
}
else if ((0, __1.typedHasProperty)(maybeError, 'message')) {
return String(maybeError.message);
}
else {
return String(error);
return String(maybeError);
}
}
exports.extractErrorMessage = extractErrorMessage;
function ensureError(input) {
if (input instanceof Error) {
return input;
function ensureError(maybeError) {
if (maybeError instanceof Error) {
return maybeError;
}
else {
return new Error(extractErrorMessage(input));
return new Error(extractErrorMessage(maybeError));
}
}
exports.ensureError = ensureError;
function ensureErrorAndPrependMessage(maybeError, prependMessage) {
const error = ensureError(maybeError);
error.message = `${prependMessage}: ${error.message}`;
return error;
}
exports.ensureErrorAndPrependMessage = ensureErrorAndPrependMessage;
function wrapInTry(inputs) {

@@ -46,0 +55,0 @@ try {

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

import { isPromiseLike, isTruthy } from '..';
import { isPromiseLike, isTruthy, typedHasProperty, } from '..';
export function combineErrors(errors) {

@@ -18,21 +18,29 @@ if (!errors || errors.length === 0) {

}
export function extractErrorMessage(error) {
if (!error) {
export function extractErrorMessage(maybeError) {
if (!maybeError) {
return '';
}
if (error instanceof Error) {
return error.message;
if (maybeError instanceof Error) {
return maybeError.message;
}
else if (typedHasProperty(maybeError, 'message')) {
return String(maybeError.message);
}
else {
return String(error);
return String(maybeError);
}
}
export function ensureError(input) {
if (input instanceof Error) {
return input;
export function ensureError(maybeError) {
if (maybeError instanceof Error) {
return maybeError;
}
else {
return new Error(extractErrorMessage(input));
return new Error(extractErrorMessage(maybeError));
}
}
export function ensureErrorAndPrependMessage(maybeError, prependMessage) {
const error = ensureError(maybeError);
error.message = `${prependMessage}: ${error.message}`;
return error;
}
export function wrapInTry(inputs) {

@@ -39,0 +47,0 @@ try {

@@ -8,4 +8,5 @@ import { RequireExactlyOne } from 'type-fest';

export declare function combineErrorMessages(errors?: ReadonlyArray<Error | string | undefined> | undefined): string;
export declare function extractErrorMessage(error: unknown): string;
export declare function ensureError(input: unknown): Error;
export declare function extractErrorMessage(maybeError: unknown): string;
export declare function ensureError(maybeError: unknown): Error;
export declare function ensureErrorAndPrependMessage(maybeError: unknown, prependMessage: string): Error;
export type TryWrapInputs<CallbackReturn, FallbackReturn> = {

@@ -12,0 +13,0 @@ callback: () => CallbackReturn;

{
"name": "@augment-vir/common",
"version": "14.3.1",
"version": "14.4.0",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",

@@ -5,0 +5,0 @@ "bugs": {

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