-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* progress on better error handling * wiring onError callback through module loader and resolver * fix error callbacks not being stored * update onError to be record * type alias * wiring * seems to work * update error handling contract and wire more * add command error builder * fix merge * progress on error handling * naive onError handling, not tested * progres * proress * progress on abstracting away iti * seems to work * fix tests * better typings * add doc * abstracting iti * remove onerror for this pr * feat: better way to add dependencies * fix tests
- Loading branch information
Showing
27 changed files
with
410 additions
and
1,150 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@sern/handler", | ||
"packageManager": "[email protected]", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "A complete, customizable, typesafe, & reactive framework for discord bots.", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.mjs", | ||
|
@@ -15,7 +15,6 @@ | |
}, | ||
"scripts": { | ||
"watch": "tsup --watch", | ||
"clean-modules": "rimraf node_modules/ && npm install", | ||
"lint": "eslint src/**/*.ts", | ||
"format": "eslint src/**/*.ts --fix", | ||
"build:dev": "tsup --metafile", | ||
|
@@ -47,8 +46,7 @@ | |
"@types/node": "^18.15.11", | ||
"@typescript-eslint/eslint-plugin": "5.58.0", | ||
"@typescript-eslint/parser": "5.59.1", | ||
"dependency-cruiser": "^13.0.5", | ||
"discord.js": "14.11.0", | ||
"discord.js": "^14.11.0", | ||
"esbuild": "^0.17.0", | ||
"eslint": "8.39.0", | ||
"prettier": "2.8.8", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
import type { CommandModule,Processed, EventModule } from "../../types/core-modules"; | ||
|
||
/** | ||
* @since 2.0.0 | ||
*/ | ||
export interface ErrorHandling { | ||
/** | ||
* Number of times the process should throw an error until crashing and exiting | ||
*/ | ||
keepAlive: number; | ||
|
||
/** | ||
* @deprecated | ||
* Version 4 will remove this method | ||
*/ | ||
crash(err: Error): never; | ||
/** | ||
* A function that is called on every crash. Updates keepAlive. | ||
* If keepAlive is 0, the process crashes. | ||
* A function that is called on every throw. | ||
* @param error | ||
*/ | ||
updateAlive(error: Error): void; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type { ReplyOptions } from "../../types/utility"; | ||
import type { Logging } from "../contracts"; | ||
|
||
export interface Response { | ||
type: 'fail' | 'continue'; | ||
body?: ReplyOptions; | ||
log?: { type: keyof Logging; message: unknown } | ||
} | ||
|
||
export const of = () => { | ||
const payload = { | ||
type: 'fail', | ||
body: undefined, | ||
log : undefined | ||
} as Record<PropertyKey, unknown> | ||
|
||
return { | ||
/** | ||
* @param {'fail' | 'continue'} p a status to determine if the error will | ||
* terminate your application or continue. Warning and | ||
*/ | ||
status: (p: 'fail' | 'continue') => { | ||
payload.type = p; | ||
return payload; | ||
}, | ||
/** | ||
* @param {keyof Logging} type Determine to log to logger[type]. | ||
* @param {T} message the message to log | ||
* | ||
* Log this error with the logger. | ||
*/ | ||
log: <T=string>(type: keyof Logging, message: T) => { | ||
payload.log = { type, message }; | ||
return payload; | ||
}, | ||
reply: (bodyContent: ReplyOptions) => { | ||
payload.body = bodyContent; | ||
return payload; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.