@stacksjs/error-handling 0.59.7 → 0.59.9
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/dist/index.js +3 -1
- package/package.json +1 -1
- package/src/handler.ts +6 -1
package/dist/index.js
CHANGED
|
@@ -386,8 +386,10 @@ class ErrorHandler {
|
|
|
386
386
|
}
|
|
387
387
|
static async writeErrorToFile(err) {
|
|
388
388
|
const formattedError = `[${new Date().toISOString()}] ${err.name}: ${err.message}\n`;
|
|
389
|
+
const errorsLogFilePath = logsPath("errors.log");
|
|
389
390
|
try {
|
|
390
|
-
await fs.
|
|
391
|
+
await fs.mkdir(dirname(errorsLogFilePath), { recursive: true });
|
|
392
|
+
await fs.appendFile(errorsLogFilePath, formattedError);
|
|
391
393
|
} catch (error) {
|
|
392
394
|
console.error("Failed to write to error file:", error);
|
|
393
395
|
}
|
package/package.json
CHANGED
package/src/handler.ts
CHANGED
|
@@ -30,8 +30,13 @@ export class ErrorHandler {
|
|
|
30
30
|
|
|
31
31
|
static async writeErrorToFile(err: Error) {
|
|
32
32
|
const formattedError = `[${new Date().toISOString()}] ${err.name}: ${err.message}\n`
|
|
33
|
+
const errorsLogFilePath = logsPath('errors.log')
|
|
34
|
+
|
|
33
35
|
try {
|
|
34
|
-
|
|
36
|
+
// Ensure the directory exists
|
|
37
|
+
await fs.mkdir(dirname(errorsLogFilePath), { recursive: true })
|
|
38
|
+
// Append the message to the log file
|
|
39
|
+
await fs.appendFile(errorsLogFilePath, formattedError)
|
|
35
40
|
}
|
|
36
41
|
catch (error) {
|
|
37
42
|
console.error('Failed to write to error file:', error)
|