@stacksjs/error-handling 0.64.6 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/handler.d.ts +16 -0
- package/dist/http.d.ts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +122 -2
- package/dist/index.js.map +86 -43
- package/dist/utils.d.ts +4 -0
- package/package.json +13 -25
- package/src/handler.ts +111 -28
- package/src/http.ts +6 -0
- package/src/index.ts +4 -2
- package/src/utils.ts +26 -0
- package/src/views/500.html +37 -0
package/README.md
CHANGED
|
@@ -28,16 +28,16 @@ You can now use it in your project:
|
|
|
28
28
|
```js
|
|
29
29
|
import {
|
|
30
30
|
Err,
|
|
31
|
-
Ok,
|
|
32
|
-
Result,
|
|
33
|
-
ResultAsync,
|
|
34
31
|
err,
|
|
35
32
|
errAsync,
|
|
36
33
|
fromPromise,
|
|
37
34
|
fromSafePromise,
|
|
38
35
|
fromThrowable,
|
|
36
|
+
Ok,
|
|
39
37
|
ok,
|
|
40
38
|
okAsync,
|
|
39
|
+
Result,
|
|
40
|
+
ResultAsync,
|
|
41
41
|
} from '@stacksjs/error-handling'
|
|
42
42
|
|
|
43
43
|
// ...
|
|
@@ -55,7 +55,7 @@ result.isErr() // false
|
|
|
55
55
|
### Example #2
|
|
56
56
|
|
|
57
57
|
```js
|
|
58
|
-
const command = 'bunx rimraf ./bun.lockb ./node_modules ./core/**/dist'
|
|
58
|
+
const command = 'bunx --bun rimraf ./bun.lockb ./node_modules ./core/**/dist'
|
|
59
59
|
const result = await runCommand(command, options)
|
|
60
60
|
|
|
61
61
|
if (result.isOk()) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ErrorOptions } from "@stacksjs/logging";
|
|
2
|
+
type ErrorMessage = string;
|
|
3
|
+
export declare class ErrorHandler {
|
|
4
|
+
static isTestEnvironment: boolean;
|
|
5
|
+
static shouldExitProcess: boolean;
|
|
6
|
+
static handle(err: Error | ErrorMessage | unknown, options?: ErrorOptions): Error;
|
|
7
|
+
static handleError(err: Error, options?: ErrorOptions): Error;
|
|
8
|
+
static writeErrorToFile(err: Error | unknown): Promise<void>;
|
|
9
|
+
static writeErrorToConsole(err: string | Error | unknown): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function handleError(err: string | Error | object | unknown, options?: ErrorOptions): Error;
|
|
12
|
+
interface WriteOptions {
|
|
13
|
+
logFile?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function writeToLogFile(message: string, options?: WriteOptions): Promise<void>;
|
|
16
|
+
export {};
|
package/dist/http.d.ts
ADDED
package/dist/index.d.ts
ADDED