Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds ErrorOptions to Error constructor #765

Merged
merged 3 commits into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ node 16+, npm 8+ are recommended.

### Compilation Target(s)

We target `es2015`, and publish both ES-modules and CommonJS modules.
We target `es2022`, and publish both ES-modules and CommonJS modules.

### Installation and Dependencies

Expand Down
2 changes: 1 addition & 1 deletion packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

### Requirements

- ES2015-compatible web browser (Chrome, Edge, Firefox, etc)
- ES2022-compatible web browser (Chrome, Edge, Firefox, etc)

### Install

Expand Down
4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"test": "jest --verbose",
"lint": "eslint ./",
"clean": "shx rm -rf ./dist",
"build:web-esm": "esbuild src/index.ts --bundle --external:@openfeature/core --sourcemap --target=es2016 --platform=browser --format=esm --outfile=./dist/esm/index.js --analyze",
"build:web-cjs": "esbuild src/index.ts --bundle --external:@openfeature/core --sourcemap --target=es2016 --platform=browser --format=cjs --outfile=./dist/cjs/index.js --analyze",
"build:web-esm": "esbuild src/index.ts --bundle --external:@openfeature/core --sourcemap --target=es2022 --platform=browser --format=esm --outfile=./dist/esm/index.js --analyze",
"build:web-cjs": "esbuild src/index.ts --bundle --external:@openfeature/core --sourcemap --target=es2022 --platform=browser --format=cjs --outfile=./dist/cjs/index.js --analyze",
"build:rollup-types": "rollup -c ../../rollup.config.mjs",
"build": "npm run clean && npm run build:web-esm && npm run build:web-cjs && npm run build:rollup-types",
"postbuild": "shx cp ./../../package.esm.json ./dist/esm/package.json",
Expand Down
6 changes: 3 additions & 3 deletions packages/client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ES2015", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": [
"ES2020",
"ES2022",
"DOM"
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
Expand All @@ -24,7 +24,7 @@
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "ES2020", /* Specify what module code is generated. */
"module": "ES2022", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down
4 changes: 2 additions & 2 deletions packages/nest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"test": "jest --verbose",
"lint": "eslint ./",
"clean": "shx rm -rf ./dist",
"build:esm": "esbuild src/index.ts --bundle --external:@nestjs/* --external:@openfeature/server-sdk --sourcemap --target=es2016 --platform=node --format=esm --outfile=./dist/esm/index.js --analyze",
"build:cjs": "esbuild src/index.ts --bundle --external:@nestjs/* --external:@openfeature/server-sdk --sourcemap --target=es2016 --platform=node --format=cjs --outfile=./dist/cjs/index.js --analyze",
"build:esm": "esbuild src/index.ts --bundle --external:@nestjs/* --external:@openfeature/server-sdk --sourcemap --target=es2022 --platform=node --format=esm --outfile=./dist/esm/index.js --analyze",
"build:cjs": "esbuild src/index.ts --bundle --external:@nestjs/* --external:@openfeature/server-sdk --sourcemap --target=es2022 --platform=node --format=cjs --outfile=./dist/cjs/index.js --analyze",
"build:rollup-types": "rollup -c ../../rollup.config.mjs",
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:rollup-types",
"postbuild": "shx cp ./../../package.esm.json ./dist/esm/package.json",
Expand Down
6 changes: 3 additions & 3 deletions packages/nest/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ES2015",
"target": "ES2022",
/* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": [
"ES2020"
"ES2022"
],
/* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
Expand All @@ -27,7 +27,7 @@
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "ES2020",
"module": "ES2022",
/* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node",
Expand Down
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"test": "jest --verbose",
"lint": "eslint ./",
"clean": "shx rm -rf ./dist",
"build:react-esm": "esbuild src/index.ts --bundle --external:react --external:@openfeature/web-sdk --sourcemap --target=es2016 --platform=browser --format=esm --outfile=./dist/esm/index.js --analyze",
"build:react-cjs": "esbuild src/index.ts --bundle --external:react --external:@openfeature/web-sdk --sourcemap --target=es2016 --platform=browser --format=cjs --outfile=./dist/cjs/index.js --analyze",
"build:react-esm": "esbuild src/index.ts --bundle --external:react --external:@openfeature/web-sdk --sourcemap --target=es2022 --platform=browser --format=esm --outfile=./dist/esm/index.js --analyze",
"build:react-cjs": "esbuild src/index.ts --bundle --external:react --external:@openfeature/web-sdk --sourcemap --target=es2022 --platform=browser --format=cjs --outfile=./dist/cjs/index.js --analyze",
"build:rollup-types": "rollup -c ../../rollup.config.mjs",
"build": "npm run clean && npm run build:react-esm && npm run build:react-cjs && npm run build:rollup-types",
"postbuild": "shx cp ./../../package.esm.json ./dist/esm/package.json",
Expand Down
6 changes: 3 additions & 3 deletions packages/react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ES2015", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": [
"ES2020",
"ES2022",
"DOM"
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
Expand All @@ -25,7 +25,7 @@
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "ES2020", /* Specify what module code is generated. */
"module": "ES2022", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down
4 changes: 2 additions & 2 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"test": "jest --verbose",
"lint": "eslint ./",
"clean": "shx rm -rf ./dist",
"build:esm": "esbuild src/index.ts --bundle --external:@openfeature/core --sourcemap --target=es2016 --platform=node --format=esm --outfile=./dist/esm/index.js --analyze",
"build:cjs": "esbuild src/index.ts --bundle --external:@openfeature/core --sourcemap --target=es2016 --platform=node --format=cjs --outfile=./dist/cjs/index.js --analyze",
"build:esm": "esbuild src/index.ts --bundle --external:@openfeature/core --sourcemap --target=es2022 --platform=node --format=esm --outfile=./dist/esm/index.js --analyze",
"build:cjs": "esbuild src/index.ts --bundle --external:@openfeature/core --sourcemap --target=es2022 --platform=node --format=cjs --outfile=./dist/cjs/index.js --analyze",
"build:rollup-types": "rollup -c ../../rollup.config.mjs",
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:rollup-types",
"postbuild": "shx cp ./../../package.esm.json ./dist/esm/package.json",
Expand Down
6 changes: 3 additions & 3 deletions packages/server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ES2015", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": [
"ES2020",
"ES2022",
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
Expand All @@ -23,7 +23,7 @@
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "ES2020", /* Specify what module code is generated. */
"module": "ES2022", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"lint": "eslint ./",
"clean": "shx rm -rf ./dist",
"type": "tsc --project ./tsconfig.json --declaration --emitDeclarationOnly",
"build:esm": "esbuild src/index.ts --bundle --external:events --sourcemap --target=es2016 --format=esm --outfile=./dist/esm/index.js --analyze",
"build:cjs": "esbuild src/index.ts --bundle --external:events --sourcemap --target=es2016 --format=cjs --outfile=./dist/cjs/index.js --analyze",
"build:esm": "esbuild src/index.ts --bundle --external:events --sourcemap --target=es2022 --format=esm --outfile=./dist/esm/index.js --analyze",
"build:cjs": "esbuild src/index.ts --bundle --external:events --sourcemap --target=es2022 --format=cjs --outfile=./dist/cjs/index.js --analyze",
"build:rollup-types": "rollup -c ../../rollup.config.mjs",
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:rollup-types",
"postbuild": "shx cp ./../../package.esm.json ./dist/esm/package.json",
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/errors/flag-not-found-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ErrorCode } from '../evaluation';

export class FlagNotFoundError extends OpenFeatureError {
code: ErrorCode;
constructor(message?: string) {
super(message);
constructor(message?: string, options?: ErrorOptions) {
super(message, options);
Object.setPrototypeOf(this, FlagNotFoundError.prototype);
this.name = 'FlagNotFoundError';
this.code = ErrorCode.FLAG_NOT_FOUND;
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/errors/general-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ErrorCode } from '../evaluation';

export class GeneralError extends OpenFeatureError {
code: ErrorCode;
constructor(message?: string) {
super(message);
constructor(message?: string, options?: ErrorOptions) {
super(message, options);
Object.setPrototypeOf(this, GeneralError.prototype);
this.name = 'GeneralError';
this.code = ErrorCode.GENERAL;
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/errors/invalid-context-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ErrorCode } from '../evaluation';

export class InvalidContextError extends OpenFeatureError {
code: ErrorCode;
constructor(message?: string) {
super(message);
constructor(message?: string, options?: ErrorOptions) {
super(message, options);
Object.setPrototypeOf(this, InvalidContextError.prototype);
this.name = 'InvalidContextError';
this.code = ErrorCode.INVALID_CONTEXT;
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/errors/open-feature-error-abstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ErrorCode } from '../evaluation';

export abstract class OpenFeatureError extends Error {
abstract code: ErrorCode;
constructor(message?: string) {
super(message);
constructor(message?: string, options?: ErrorOptions) {
super(message, options);
Object.setPrototypeOf(this, OpenFeatureError.prototype);
this.name = 'OpenFeatureError';
}
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/errors/parse-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ErrorCode } from '../evaluation';

export class ParseError extends OpenFeatureError {
code: ErrorCode;
constructor(message?: string) {
super(message);
constructor(message?: string, options?: ErrorOptions) {
super(message, options);
Object.setPrototypeOf(this, ParseError.prototype);
this.name = 'ParseError';
this.code = ErrorCode.PARSE_ERROR;
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/errors/provider-not-ready-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ErrorCode } from '../evaluation';

export class ProviderNotReadyError extends OpenFeatureError {
code: ErrorCode;
constructor(message?: string) {
super(message);
constructor(message?: string, options?: ErrorOptions) {
super(message, options);
Object.setPrototypeOf(this, ProviderNotReadyError.prototype);
this.name = 'ProviderNotReadyError';
this.code = ErrorCode.PROVIDER_NOT_READY;
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/errors/targeting-key-missing-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ErrorCode } from '../evaluation';

export class TargetingKeyMissingError extends OpenFeatureError {
code: ErrorCode;
constructor(message?: string) {
super(message);
constructor(message?: string, options?: ErrorOptions) {
super(message, options);
Object.setPrototypeOf(this, TargetingKeyMissingError.prototype);
this.name = 'TargetingKeyMissingError';
this.code = ErrorCode.TARGETING_KEY_MISSING;
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/errors/type-mismatch-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ErrorCode } from '../evaluation';

export class TypeMismatchError extends OpenFeatureError {
code: ErrorCode;
constructor(message?: string) {
super(message);
constructor(message?: string, options?: ErrorOptions) {
super(message, options);
Object.setPrototypeOf(this, TypeMismatchError.prototype);
this.name = 'TypeMismatchError';
this.code = ErrorCode.TYPE_MISMATCH;
Expand Down
6 changes: 3 additions & 3 deletions packages/shared/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ES2015", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": [
"ES2020"
"ES2022"
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
Expand All @@ -23,7 +23,7 @@
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "ES2020", /* Specify what module code is generated. */
"module": "ES2022", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
/* Language and Environment */
"target": "ES2015", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": [
"ES2020",
"ES2022",
"DOM"
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
Expand All @@ -24,7 +24,7 @@
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
/* Modules */
"module": "ES2020", /* Specify what module code is generated. */
"module": "ES2022", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
Expand Down