-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: hibakezelés javított kommunikációval
- Loading branch information
Showing
4 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
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,4 +1,5 @@ | ||
node_modules/ | ||
szamlak/ | ||
temp/ | ||
.env | ||
.env | ||
error.log |
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,8 @@ | ||
#!/usr/bin/env node | ||
const SingleInstance = require('single-instance'); | ||
const { start } = require('./src/main'); | ||
const { handleError } = require('./src/err'); | ||
|
||
new SingleInstance('dijnet-bot').lock().then(start).catch(_ => { | ||
console.log('A Díjnet bot már fut, és nem futtatható több példányban.'); | ||
new SingleInstance('dijnet-bot').lock().then(start).catch(error => { | ||
handleError(error.stack ? error : 'A Díjnet bot már fut, és nem futtatható több példányban.'); | ||
}); |
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,20 @@ | ||
const fs = require('fs'); | ||
const chalk = require('chalk'); | ||
|
||
const fn = './error.log'; | ||
|
||
function printRed(message) { | ||
console.log(chalk.red(message)); | ||
} | ||
|
||
function handleError(error) { | ||
if (error.message && error.stack) { | ||
printRed(`\nHa biztos vagy abban, hogy a Díjnet felhasználóneved és jelszavad, valamint a konfigurációs paramétereket helyesen adtad meg, akkor a hiba a programban lehet.\n\nA hiba részleteit megtalálod az ${fn} fájlban. Kérlek, az alábbi linken nyiss egy új issue-t, másold be az ${fn} fájl tartalmát, és írd le röviden, milyen szituációban jelentkezett a hiba!\n\n--> https://github.com/juzraai/dijnet-bot/issues\n`); | ||
fs.writeFileSync(fn, `${error.message}\n${error.stack}`); | ||
} else { | ||
printRed(error); | ||
} | ||
process.exit(1); | ||
} | ||
|
||
module.exports = { handleError }; |
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