From 41a4828ecc08fba530b84b82c44c308b8cb6fd4b Mon Sep 17 00:00:00 2001 From: INeedJobToStartWork Date: Mon, 25 Nov 2024 20:57:03 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20Feat(oh-my-error)!:=20Realise=20?= =?UTF-8?q?`2.0.0`=20version!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/honest-jeans-own.md | 8 --- .changeset/pre.json | 8 --- .changeset/short-eels-sparkle.md | 7 --- packages/oh-my-error/CHANGELOG.md | 33 ++++++++++++ packages/oh-my-error/README.md | 69 ++++++++++++-------------- packages/oh-my-error/package.json | 2 +- tutorials/EveryThingAbout/CHANGELOG.md | 9 ++++ tutorials/EveryThingAbout/package.json | 2 +- 8 files changed, 77 insertions(+), 61 deletions(-) delete mode 100644 .changeset/honest-jeans-own.md delete mode 100644 .changeset/pre.json delete mode 100644 .changeset/short-eels-sparkle.md create mode 100644 tutorials/EveryThingAbout/CHANGELOG.md diff --git a/.changeset/honest-jeans-own.md b/.changeset/honest-jeans-own.md deleted file mode 100644 index 4108a8a..0000000 --- a/.changeset/honest-jeans-own.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -"oh-my-error": minor ---- - -- Add passing Throwed Error to our error at `myErrorWrapper` -- Add types `TValueOrFunctionAll` and `TValueOrFunction` -- Add missing TSDocs to types -- Change myErrorHandler arg[0] type (added unknown) diff --git a/.changeset/pre.json b/.changeset/pre.json deleted file mode 100644 index 9974e36..0000000 --- a/.changeset/pre.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "mode": "pre", - "tag": "prerelease", - "initialVersions": { - "oh-my-error": "2.0.0-prerelease.1" - }, - "changesets": ["honest-jeans-own", "short-eels-sparkle"] -} diff --git a/.changeset/short-eels-sparkle.md b/.changeset/short-eels-sparkle.md deleted file mode 100644 index 3062ecc..0000000 --- a/.changeset/short-eels-sparkle.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"oh-my-error": major ---- - -- Add type `StatusCode` -- Add missing TSDocs -- Change enum StatusCode to object diff --git a/packages/oh-my-error/CHANGELOG.md b/packages/oh-my-error/CHANGELOG.md index 23058f4..358e6a3 100644 --- a/packages/oh-my-error/CHANGELOG.md +++ b/packages/oh-my-error/CHANGELOG.md @@ -1,5 +1,38 @@ # oh-my-error +## 2.0.0 + +### Major Changes + +- 4c9780c: - Add type `StatusCode` + - Add missing TSDocs + - Change enum StatusCode to object +- 4f04fe2: - Add new Error Types, New Functions and Features to current existing functions + - Add `statusCodes` enum. + - Refactored `MyError` => `myError`, currently it's error object handler before throw. + - Added new Feature to `myErrorWrapper` - Instant throw error, no need to use condition with `isError` to throw Error. + - Added `myErrorWrapperAsync` which is `myErrorWrapper` alternative for async functions. + - Refactored `TMyError` - renamed `TMyError` => `IMyError`, changed from `type` to `interface` and structure. + - Add new Error (Organism) Interfaces `IMyError`,`IMyErrorAPI`,`IMyErrorRateLimit`,`IMyErrorValidation` + - Add new Error (Atom) types + `TSeverity`,`TSeverity2`,`TErrorMessages`,`TErrorMessagesExt`,`TMyErrorList`,`TErrorList`,`TCauseError`,`TDetails`,`TBaseError`,`TBaseErrorExt`,`TValidationError`,`TApiError`,`TApiRateLimit`, + +### Minor Changes + +- b9d8ffa: - Add passing Throwed Error to our error at `myErrorWrapper` + - Add types `TValueOrFunctionAll` and `TValueOrFunction` + - Add missing TSDocs to types + - Change myErrorHandler arg[0] type (added unknown) +- 12098d8: - Add new Error Types, New Functions and Features to current existing functions + - `myErrorWrapperAsync` implemented to current `myErrorWrapper` + - `myErrorWrapperAsync` removed + +### Patch Changes + +- 4c9780c: - Add type `StatusCode` + - Add missing TSDocs + - Change enum StatusCode to object + ## 2.0.0-prerelease.3 ### Minor Changes diff --git a/packages/oh-my-error/README.md b/packages/oh-my-error/README.md index c6f2ea7..be77ff4 100644 --- a/packages/oh-my-error/README.md +++ b/packages/oh-my-error/README.md @@ -1,7 +1,7 @@ ![image](https://github.com/INeedJobToStartWork/MyError/assets/97305201/03fa3e50-af28-4345-a3f7-f84d091b4eb1)

MyError

-

πŸŽ‰2.0.0.prerelease.3🎊

+

πŸŽ‰2.0.0🎊

A Very Clean Error Handler!

πŸ“—Tutorials | @@ -35,9 +35,9 @@ What you get: // Instead let data; try { - data = readFile("...path"); + data = readFile("...path"); } catch { - throw Error("Cant Load File!"); + throw Error("Cant Load File!"); } // Do @@ -116,11 +116,11 @@ Processes an error object, invoking functions with provided arguments ```ts const MyErrorList = { - BLACKLISTED: { - name: "Black Listed Name", - hint: "Try use other one!", - message: (name: string) => `${name} is on black list!`, - }, + BLACKLISTED: { + name: "Black Listed Name", + hint: "Try use other one!", + message: (name: string) => `${name} is on black list!` + } } as const satisfies TMyErrorList; throw new myError(MyErrorList.BLACKLISTED, { message: ["nameInputed"] }); @@ -164,10 +164,7 @@ const data = myErrorWrapper(readFile,err => new Error(`ERROR MESSAGE: ${err.mess > At async function it returns Promise, just use `await` to solve that ```ts -const data = await myErrorWrapper( - asyncFun, - new Error("Oh, Error!") -)("MyString"); +const data = await myErrorWrapper(asyncFun, new Error("Oh, Error!"))("MyString"); ``` ### myErrorCatcher @@ -176,8 +173,8 @@ const data = await myErrorWrapper( ```ts const data = await myErrorCatcher(readFile)("path...").catch(() => { - // Code before crash... - throw new Error("Can't read file!"); + // Code before crash... + throw new Error("Can't read file!"); }); ``` @@ -189,10 +186,10 @@ Execute Scenarios for an error! const [data, isError] = myErrorWrapper(readFile)("./ReadThisFile"); const MyErrorHandlerList = { - FS001: () => { - // Do this code if throw this error - console.error("ERROR"); - }, + FS001: () => { + // Do this code if throw this error + console.error("ERROR"); + } }; if (isError) myErrorHandler(data.code, MyErrorHandlerList)(); ``` @@ -211,24 +208,24 @@ if (isError) myErrorHandler(data.code, MyErrorHandlerList)(); ```ts const ErrorList = { - notFound: { - name: "Not Found", - code: "FS001", - message: { - user: "File not found", - dev: "The file you are trying to read does not exist", - }, - hint: (path: string) => `Check if the file exists at ${path}`, - } satisfies IMyError, - cantRead: { - code: "FS002", - name: "Cant Read", - message: { user: "Can't read file", dev: "readFileSync throw error" }, - hint: { - user: "Check if the file is not corrupted or permissions", - dev: "File is corrupted or has no permissions to be read", - }, - }, + notFound: { + name: "Not Found", + code: "FS001", + message: { + user: "File not found", + dev: "The file you are trying to read does not exist" + }, + hint: (path: string) => `Check if the file exists at ${path}` + } satisfies IMyError, + cantRead: { + code: "FS002", + name: "Cant Read", + message: { user: "Can't read file", dev: "readFileSync throw error" }, + hint: { + user: "Check if the file is not corrupted or permissions", + dev: "File is corrupted or has no permissions to be read" + } + } } as const satisfies TMyErrorList; ``` diff --git a/packages/oh-my-error/package.json b/packages/oh-my-error/package.json index 64d547d..84d8554 100644 --- a/packages/oh-my-error/package.json +++ b/packages/oh-my-error/package.json @@ -1,6 +1,6 @@ { "name": "oh-my-error", - "version": "2.0.0-prerelease.3", + "version": "2.0.0", "description": "A simple error handler for nodejs", "keywords": [ "error", diff --git a/tutorials/EveryThingAbout/CHANGELOG.md b/tutorials/EveryThingAbout/CHANGELOG.md new file mode 100644 index 0000000..46c5a6a --- /dev/null +++ b/tutorials/EveryThingAbout/CHANGELOG.md @@ -0,0 +1,9 @@ +# @tutorial/alex-story + +## 1.0.1 + +### Patch Changes + +- Updated dependencies [b9d8ffa] +- Updated dependencies [4c9780c] + - oh-my-error@2.0.0 diff --git a/tutorials/EveryThingAbout/package.json b/tutorials/EveryThingAbout/package.json index 3c64d6a..6614dee 100644 --- a/tutorials/EveryThingAbout/package.json +++ b/tutorials/EveryThingAbout/package.json @@ -1,6 +1,6 @@ { "name": "@tutorial/alex-story", - "version": "1.0.0", + "version": "1.0.1", "description": "", "main": "index.js", "scripts": {