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

@litert/core

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@litert/core - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

4

CHANGES.md
# Changes Logs
## v1.0.5
- Allow using partial metadata while create new error object.
## v1.0.4

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

4

lib/Error.d.ts

@@ -108,3 +108,3 @@ /**

message?: string;
metadata?: M;
metadata?: Partial<M>;
}): IError<M>;

@@ -150,3 +150,3 @@ /**

*/
define<M2 extends M = M>(code: number | null, name: string, message: string, metadata?: M2): IErrorConstructor<M2>;
define<M2 extends M = M>(code: number | null, name: string, message: string, metadata: M2): IErrorConstructor<M2>;
/**

@@ -153,0 +153,0 @@ * Get the error constructor by its name .

@@ -210,6 +210,6 @@ "use strict";

DEFAULT_HUB = createErrorHub("@litert/core");
DEFAULT_HUB.define(null, "INVALID_ERROR_NAME", `Invalid name for error definition.`);
DEFAULT_HUB.define(null, "INVALID_ERROR_CODE", `Invalid code for error definition.`);
DEFAULT_HUB.define(null, "DUPLICATED_ERROR_NAME", `The name of new error already exists.`);
DEFAULT_HUB.define(null, "DUPLICATED_ERROR_CODE", `The code of new error already exists.`);
DEFAULT_HUB.define(null, "INVALID_ERROR_NAME", `Invalid name for error definition.`, {});
DEFAULT_HUB.define(null, "INVALID_ERROR_CODE", `Invalid code for error definition.`, {});
DEFAULT_HUB.define(null, "DUPLICATED_ERROR_NAME", `The name of new error already exists.`, {});
DEFAULT_HUB.define(null, "DUPLICATED_ERROR_CODE", `The code of new error already exists.`, {});
/**

@@ -216,0 +216,0 @@ * Get the default hub of errors.

{
"name": "@litert/core",
"version": "1.0.4",
"version": "1.0.5",
"description": "The core of LiteRT.",

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

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

const errors = Core.getDefaultErrorHub();
const TEST_ERROR = errors.define(123, "TEST_ERROR", "This is a test error.");
const TEST_ERROR = errors.define(123, "TEST_ERROR", "This is a test error.", {});
console.error(JSON.stringify(new TEST_ERROR().toJSON(true), null, 2));

@@ -28,3 +28,5 @@ const myErrors = Core.createErrorHub();

*/
const MY_TEST_ERROR1 = myErrors.define(1, "MY_TEST_ERROR1", "Custom error 1");
const MY_TEST_ERROR1 = myErrors.define(1, "MY_TEST_ERROR1", "Custom error 1", {
source: "UK"
});
/**

@@ -41,3 +43,3 @@ * Type 2 of error.

}).toJSON(true), null, 2));
if (Core.isError(new MY_TEST_ERROR2())) {
if (Core.isError(new MY_TEST_ERROR2({ metadata: {} }))) {
console.log(MY_TEST_ERROR2.message);

@@ -48,3 +50,5 @@ console.log(new MY_TEST_ERROR2().metadata.source);

try {
myErrors.define(2, "MY_TEST_ERROR2", "Custom error 2");
myErrors.define(2, "MY_TEST_ERROR2", "Custom error 2", {
source: "RU"
});
}

@@ -51,0 +55,0 @@ catch (e) {

@@ -147,3 +147,3 @@ /**

message?: string;
metadata?: M;
metadata?: Partial<M>;
}): IError<M>;

@@ -292,3 +292,3 @@

message: string,
metadata?: M2
metadata: M2
): IErrorConstructor<M2>;

@@ -500,3 +500,4 @@

"INVALID_ERROR_NAME",
`Invalid name for error definition.`
`Invalid name for error definition.`,
{}
);

@@ -507,3 +508,4 @@

"INVALID_ERROR_CODE",
`Invalid code for error definition.`
`Invalid code for error definition.`,
{}
);

@@ -514,3 +516,4 @@

"DUPLICATED_ERROR_NAME",
`The name of new error already exists.`
`The name of new error already exists.`,
{}
);

@@ -521,3 +524,4 @@

"DUPLICATED_ERROR_CODE",
`The code of new error already exists.`
`The code of new error already exists.`,
{}
);

@@ -524,0 +528,0 @@

@@ -23,3 +23,3 @@ /**

const TEST_ERROR = errors.define(123, "TEST_ERROR", "This is a test error.");
const TEST_ERROR = errors.define(123, "TEST_ERROR", "This is a test error.", {});

@@ -41,3 +41,6 @@ console.error(JSON.stringify(new TEST_ERROR().toJSON(true), null, 2));

"MY_TEST_ERROR1",
"Custom error 1"
"Custom error 1",
{
source: "UK"
}
);

@@ -63,3 +66,3 @@

if (Core.isError(new MY_TEST_ERROR2())) {
if (Core.isError(new MY_TEST_ERROR2({ metadata: {} }))) {

@@ -76,3 +79,6 @@ console.log(MY_TEST_ERROR2.message);

"MY_TEST_ERROR2",
"Custom error 2"
"Custom error 2",
{
source: "RU"
}
);

@@ -79,0 +85,0 @@ }

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