Socket
Socket
Sign inDemoInstall

@syncot/error

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@syncot/error - npm Package Compare versions

Comparing version 0.0.6 to 0.1.0

CHANGELOG.md

5

lib/error.d.ts

@@ -121,1 +121,6 @@ export interface ErrorDetails {

export declare function isCompositeError(error: any): error is CompositeError;
export interface AssertError extends Error {
name: 'SyncOtError Assert';
}
export declare function createAssertError(message?: string): AssertError;
export declare function isAssertError(error: any): error is AssertError;

31

lib/error.js

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

import { strict as assert } from 'assert';
function assert(value, message) {
if (!value) {
throw createAssertError(message);
}
}
/**

@@ -7,7 +11,7 @@ * Creates a new Error instance with the specified properties.

export function createError(details = {}) {
assert.ok(details != null && typeof details === 'object', 'Argument "details" must be an object.');
assert.ok(typeof details.name === 'string' || details.name === undefined, 'Argument "details.name" must be a string or undefined.');
assert.ok(typeof details.message === 'string' || details.message === undefined, 'Argument "details.message" must be a string or undefined.');
assert.ok(details.cause instanceof Error || details.cause === undefined, 'Argument "details.cause" must be an Error or undefined.');
assert.ok(!('stack' in details), 'Argument "details.stack" must not be present.');
assert(details != null && typeof details === 'object', 'Argument "details" must be an object.');
assert(typeof details.name === 'string' || details.name === undefined, 'Argument "details.name" must be a string or undefined.');
assert(typeof details.message === 'string' || details.message === undefined, 'Argument "details.message" must be a string or undefined.');
assert(details.cause instanceof Error || details.cause === undefined, 'Argument "details.cause" must be an Error or undefined.');
assert(!('stack' in details), 'Argument "details.stack" must not be present.');
const name = details.name;

@@ -58,4 +62,4 @@ const cause = details.cause;

export function createInvalidEntityError(entityName, entity, key = null) {
assert.ok(typeof entityName === 'string', 'Argument "entityName" must be a string.');
assert.ok(typeof key === 'string' || key === null, 'Argument "key" must be a string or null.');
assert(typeof entityName === 'string', 'Argument "entityName" must be a string.');
assert(typeof key === 'string' || key === null, 'Argument "key" must be a string or null.');
return createError({

@@ -75,3 +79,3 @@ entity,

export function createTypeNotFoundError(typeName) {
assert.ok(typeof typeName === 'string', 'Argument "typeName" must be a string.');
assert(typeof typeName === 'string', 'Argument "typeName" must be a string.');
return createError({

@@ -221,1 +225,10 @@ message: `Type "${typeName}" not found.`,

}
export function createAssertError(message) {
return createError({
message,
name: 'SyncOtError Assert',
});
}
export function isAssertError(error) {
return error instanceof Error && error.name === 'SyncOtError Assert';
}
{
"name": "@syncot/error",
"version": "0.0.6",
"description": "Helpers for managing errors.",
"version": "0.1.0",
"description": "Utilities for managing errors.",
"keywords": [

@@ -23,3 +23,3 @@ "error"

"engines": {
"node": ">=12.0.0"
"node": ">=8.0.0"
},

@@ -32,3 +32,3 @@ "publishConfig": {

},
"gitHead": "f42e7403c10d1236587af99fc13d35b2a27a55ad"
"gitHead": "826d566f85342309a513529839aca7a5aeb5815e"
}
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