mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 11:30:12 +08:00
fix: add error handling
This commit is contained in:
1 parent
eb9118d5b1
commit
c7f52b1003
1 file changed
+18
@@ -50,9 +50,18 @@ export default class CommandHandler extends SessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async discoverHandler() {
|
async discoverHandler() {
|
||||||
|
try {
|
||||||
const graph = new FileGraph(this.session.graph)
|
const graph = new FileGraph(this.session.graph)
|
||||||
graph.discover(this.params.discover)
|
graph.discover(this.params.discover)
|
||||||
this.session.graph = graph
|
this.session.graph = graph
|
||||||
|
} catch (e) {
|
||||||
|
logger.error('Update file graph failed', {
|
||||||
|
error: e,
|
||||||
|
session: this.session.id,
|
||||||
|
graph: this.session.graph,
|
||||||
|
discover: this.params.discover,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async isMatch(condition) {
|
async isMatch(condition) {
|
||||||
@@ -111,6 +120,7 @@ export default class CommandHandler extends SessionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async run() {
|
async run() {
|
||||||
|
try {
|
||||||
this.quest = await Quest.findById(this.session.quest)
|
this.quest = await Quest.findById(this.session.quest)
|
||||||
const stages = this.getStages()
|
const stages = this.getStages()
|
||||||
if (stages.length === 0) {
|
if (stages.length === 0) {
|
||||||
@@ -143,5 +153,13 @@ export default class CommandHandler extends SessionHandler {
|
|||||||
end: this.session.status === 'finished',
|
end: this.session.status === 'finished',
|
||||||
...response,
|
...response,
|
||||||
}
|
}
|
||||||
|
} catch (err) {
|
||||||
|
logger.error('CommandHandler error', {
|
||||||
|
error: err,
|
||||||
|
session: this.session.id,
|
||||||
|
command: this.commandInput,
|
||||||
|
})
|
||||||
|
return {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user