Socket
Socket
Sign inDemoInstall

@visulima/error

Package Overview
Dependencies
Maintainers
0
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visulima/error - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

dist/code-frame/index.cjs

10

CHANGELOG.md

@@ -0,1 +1,11 @@

## @visulima/error [4.1.0](https://github.com/visulima/visulima/compare/@visulima/error@4.0.0...@visulima/error@4.1.0) (2024-07-01)
### Features
* **error:** added new error serialize ([#443](https://github.com/visulima/visulima/issues/443)) ([b6f109b](https://github.com/visulima/visulima/commit/b6f109b108e608e310ec1bc95de7e249763ad095))
### Miscellaneous Chores
* updated dev dependencies ([c889486](https://github.com/visulima/visulima/commit/c889486f8980741f459b993648c1b6d0815e3d66))
## @visulima/error [4.0.0](https://github.com/visulima/visulima/compare/@visulima/error@3.2.11...@visulima/error@4.0.0) (2024-06-16)

@@ -2,0 +12,0 @@

22

dist/error/index.d.ts
declare const getErrorCauses: <E = unknown>(error: E) => E[];
type SerializedError<ErrorType = Error> = Record<PropertyKey, unknown> & {
aggregateErrors?: SerializedError<ErrorType>[];
cause?: unknown;
code?: string;
message: string;
name: string;
raw?: ErrorType;
stack?: string;
};
interface JsonError extends Error {
toJSON: () => SerializedError;
}
type Options = {
exclude?: string[];
maxDepth?: number;
useToJSON?: boolean;
};
declare const serialize: (error: AggregateError | Error | JsonError, options?: Options) => SerializedError;
interface ErrorProperties {

@@ -31,2 +51,2 @@ hint?: ErrorHint;

export { type ErrorHint, type ErrorLocation, type ErrorProperties, VisulimaError, getErrorCauses, isVisulimaError };
export { type ErrorHint, type ErrorLocation, type ErrorProperties, type Options as ErrorWithCauseSerializerOptions, type SerializedError, VisulimaError, getErrorCauses, isVisulimaError, serialize as serializeError };

2

dist/index.d.ts
export { CODE_FRAME_POINTER, CodeFrameLocation, CodeFrameNodeLocation, CodeFrameOptions, ColorizeMethod, codeFrame } from './code-frame/index.js';
export { ErrorHint, ErrorLocation, ErrorProperties, VisulimaError, getErrorCauses, isVisulimaError } from './error/index.js';
export { ErrorHint, ErrorLocation, ErrorProperties, ErrorWithCauseSerializerOptions, SerializedError, VisulimaError, getErrorCauses, isVisulimaError, serializeError } from './error/index.js';
export { Trace, TraceType, parseStacktrace } from './stacktrace/index.js';

@@ -4,0 +4,0 @@

@@ -22,1 +22,28 @@ MIT License

SOFTWARE.
<!-- DEPENDENCIES -->
# Licenses of bundled dependencies
The published @visulima/error artifact additionally contains code with the following licenses:
MIT
# Bundled dependencies:
## is-plain-obj
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/is-plain-obj
> MIT License
>
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<!-- DEPENDENCIES -->
<!-- TYPE_DEPENDENCIES -->
<!-- TYPE_DEPENDENCIES -->
{
"name": "@visulima/error",
"version": "4.0.0",
"version": "4.1.0",
"description": "Error with more than just a message, stacktrace parsing.",

@@ -55,23 +55,39 @@ "keywords": [

".": {
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
},
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
}
},
"./code-frame": {
"require": {
"types": "./dist/code-frame/index.d.cts",
"default": "./dist/code-frame/index.cjs"
},
"import": {
"types": "./dist/code-frame/index.d.ts",
"default": "./dist/code-frame/index.js"
"types": "./dist/code-frame/index.d.mts",
"default": "./dist/code-frame/index.mjs"
}
},
"./error": {
"require": {
"types": "./dist/error/index.d.cts",
"default": "./dist/error/index.cjs"
},
"import": {
"types": "./dist/error/index.d.ts",
"default": "./dist/error/index.js"
"types": "./dist/error/index.d.mts",
"default": "./dist/error/index.mjs"
}
},
"./stacktrace": {
"require": {
"types": "./dist/stacktrace/index.d.cts",
"default": "./dist/stacktrace/index.cjs"
},
"import": {
"types": "./dist/stacktrace/index.d.ts",
"default": "./dist/stacktrace/index.js"
"types": "./dist/stacktrace/index.d.mts",
"default": "./dist/stacktrace/index.mjs"
}

@@ -81,2 +97,4 @@ },

},
"main": "dist/index.cjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",

@@ -104,4 +122,4 @@ "files": [

"@types/node": "18.19.15",
"@visulima/nextra-theme-docs": "4.0.26",
"@visulima/path": "1.0.2",
"@visulima/nextra-theme-docs": "4.0.26",
"@vitest/coverage-v8": "^1.6.0",

@@ -115,2 +133,3 @@ "@vitest/ui": "^1.6.0",

"eslint-plugin-mdx": "^3.1.5",
"is-plain-obj": "^4.1.0",
"eslint-plugin-vitest": "^0.4.1",

@@ -121,3 +140,4 @@ "eslint-plugin-vitest-globals": "^1.5.0",

"semantic-release": "24.0.0",
"tsup": "^8.1.0",
"@visulima/packem": "^1.0.0-alpha.46",
"esbuild": "^0.21.5",
"typescript": "^5.4.5",

@@ -151,11 +171,5 @@ "vitest": "^1.6.0"

},
"sources": [
"src/index.ts",
"src/code-frame/index.ts",
"src/error/index.ts",
"src/stacktrace/index.ts"
],
"scripts": {
"build": "cross-env NODE_ENV=development tsup",
"build:prod": "cross-env NODE_ENV=production tsup",
"build": "cross-env NODE_ENV=development packem build",
"build:prod": "cross-env NODE_ENV=production packem build",
"clean": "rimraf node_modules dist .eslintcache",

@@ -162,0 +176,0 @@ "dev": "pnpm run build --watch",

@@ -231,2 +231,28 @@ <div align="center">

## `serialize` an error object
- Ensures errors are safe to serialize with JSON
- Can be used as error.toJSON()
- Deep serialization, including transforming
- Custom serialization (e.g. YAML or process.send())
- Keeps both native (TypeError, etc.) and custom error classes
- Preserves errors' additional properties
- Can keep constructor's arguments
- Works recursively with error.cause and AggregateError
- Buffer properties are replaced with [object Buffer]
- Circular references are handled.
- If the input object has a .toJSON() method, then it's called instead of serializing the object's properties.
- It's up to .toJSON() implementation to handle circular references and enumerability of the properties.
```ts
import { serializeError } from "@visulima/error";
const error = new TypeError("example");
const errorObject = serializeError(error);
// Plain object: { name: 'TypeError', message: 'example', stack: '...' }
const errorString = JSON.stringify(errorObject);
const newErrorObject = JSON.parse(errorString);
```
## Supported Node.js Versions

@@ -233,0 +259,0 @@

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