flex-development / exceptions Goto Github PK
View Code? Open in Web Editor NEW๐ง Custom error classes and utilities
Home Page: https://github.com/flex-development/exceptions
License: BSD 3-Clause "New" or "Revised" License
๐ง Custom error classes and utilities
Home Page: https://github.com/flex-development/exceptions
License: BSD 3-Clause "New" or "Revised" License
Using @flex-development/[email protected]
in a Next.js project yields a DeprecationWarning
:
info - Creating an optimized production build...
(node:13935) [DEP0128] DeprecationWarning: Invalid 'main' field in '/Users/lex/Projects/FLDV/TEMPLATES/unistack/apps/web/node_modules/@flex-development/exceptions/package.json' of 'dist/index.js'. Please either fix that or report it to the module author
(Use `node --trace-deprecation ...` to show where the warning was created)
[email protected]
@flex-development/[email protected]
next build
A DeprecationWarning
should not be thrown when using @flex-development/[email protected]
.
N/A
v16.6.0
macOS v11.3.1
[email protected]
@flex-development/[email protected]
The create-dist-package-json script used in @flex-development/exceptions
contains the logic to update the package main
field, but it seems it didn't work properly for v2.0.1
. Additionally, since first releasing this project, our organization's package build, publish, and release workflows have undergone major changes. Those updates should be implemented in this repository.
N/A
Node.js 15 updates the JavaScript engine to V8 8.6
, which introduces the AggregateError
class. As explained in the MDN docs, the AggregateError
class groups several errors together:
The AggregateError object represents an error when several errors need to be wrapped in a single error. It is thrown when
multiple errors need to be reported by an operation
Despite the current type definition for Exception#errors
allowing for more than array types, a more appropriate superclass for Exception
would be AggregateError
seeing that the property name indicates a group of errors.
This update would introduce several changes:
Refactor data transfer objects, interfaces, and type definitions
/**
* `Exception` data transfer object.
*
* @template T - Aggregated error type
*/
export interface ExceptionDataDTO<T extends any = any> { ... }
/**
* JSON representation of an `Exception`.
*
* @template T - Aggregated error type
*/
export interface ExceptionJSON<T extends any = any> { ... }
/**
* Exception#errors` shape.
*
* @template T - Aggregated error type
*/
export type ExceptionErrors<T extends any = any> = Array<T>
Convert Exception
into a generic and extend AggregateError
/**
* @template T - Aggregated error type
*
* @extends {AggregateError}
*/
class Exception<T extends any = any> extends AggregateError { ... }
Note:
ExceptionErrors
is a breaking changeAggregateError
classAdditionally, we should take this opportunity to enforce (mostly) proper Error subclassing. Aside from the class naming rule, all rules defined by eslint-plugin-unicorn
rule unicorn/custom-error-definition
should be followed. This also requires a breaking change - we need to rename ExceptionName as well as update all associated naming logic.
User goals | Usage frequency | Difficulty scale |
---|---|---|
ie. What the user wants to accomplish | ie. Daily, weekly, monthly, yearly | ie. Scale of 1 - 5 |
refactor Exception to extend AggregateError instead of Error |
daily | 1 |
refactor Exception to extend AggregateError instead of Error |
daily | 1 |
The original intention for this package was to implement a consistent Error
subclass API as well as provide stricter type definitions than the @feathers/errors
library. This update makes existing type definitions stricter and subsequently improves consistency when working with Exception
class objects. If this request is implemented, users no longer have to check if Exception#errors
is an array, object, or string. The property will always be an array, and therefore users can always use Array
APIs when interfacing with Exception#errors
property.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.