![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
A library that simplifies error handling by providing an ES6 error class and utility functions. This library facilitates the extraction of options and error messages from constructor arguments.
Table of Contents
npm install ebec --save
The BaseError class accepts various constructor arguments of type Input and any Options specified during initialization are automatically assigned as attributes.
Create error instances in different ways, as demonstrated in the following examples:
Example #1
import { BaseError } from 'ebec';
const error = new BaseError('An error occurred.');
console.log(error.message);
// An error occurred.
Example #2
In this example, only error options are passed as a single argument to the error constructor.
import { BaseError } from 'ebec';
const error = new BaseError({
message: 'The entity could not be found',
code: 'BAD_REQUEST'
});
console.log(error.message);
// The entity could not be found
console.log(error.code);
// BAD_REQUEST
Example #3
In this example, multiple arguments are passed to the error constructor.
import { BaseError } from 'ebec';
const cause = new Error('foo');
const error = new BaseError(
'The entity could not be found',
{
code: 'BAD_REQUEST'
},
cause
);
console.log(error.message);
// The entity could not be found
console.log(error.code);
// BAD_REQUEST
console.log(error.cause);
// { message: 'foo', ... }
Custom error classes that inherit from BaseError allow for more specific error handling.
import {
BaseError,
Options
} from 'ebec';
export class NotFoundError extends BaseError {
constructor(message?: string) {
super({
message,
logMessage: true,
logLevel: 'warning',
code: 'NOT_FOUND'
});
}
}
type Input = Options | Error | string;
type Options = {
/**
* The actual error message, if not provided on another way.
*/
message?: string,
/**
* Trace of which functions were called.
*/
stack?: string
/**
* A unique identifier for the error,
* which can be a short uppercase string or a numeric code.
*/
code?: string | number | null,
/**
* Additional data associated with the error. This property can hold
* unstructured information or supplementary details that provide context
* to the error.
*/
data?: unknown,
/**
* Determines whether the error message can be safely exposed externally.
*/
expose?: boolean;
/**
* Indicates whether the error should be logged in the application's logs.
*/
logMessage?: boolean,
/**
* Specifies the log level at which this error should be recorded.
*/
logLevel?: string | number,
/**
* Represents the underlying cause or source of the error.
*/
cause?: unknown
};
This method is used to determine if the error is a basic error or if the error extends this class.
import { isBaseError, BaseError } from "ebec";
const error = new BaseError();
console.log(isBaseError(error));
// true
Made with 💚
Published under MIT License.
FAQs
A library that provides a basic ES6 error class.
We found that ebec demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.