From b69b1fea16250421bc7d5def1c973dd43e453071 Mon Sep 17 00:00:00 2001 From: louistiti Date: Sat, 11 Jun 2022 10:01:47 +0800 Subject: [PATCH] feat(server): report full traceback from skills execution --- bridges/python/main.py | 8 +++++++- server/src/core/nlu.js | 12 ++++++++++-- skills/leon/introduction/nlu/en.json | 2 +- skills/leon/introduction/src/actions/remember.py | 6 +++--- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bridges/python/main.py b/bridges/python/main.py index 8589d4de3..c962aa965 100644 --- a/bridges/python/main.py +++ b/bridges/python/main.py @@ -2,6 +2,7 @@ # -*- coding:utf-8 -*- import utils +from traceback import print_exc from sys import path from json import dumps, loads from importlib import import_module @@ -27,4 +28,9 @@ def main(): return getattr(skill, intent_obj['action'])(params) if __name__ == '__main__': - main() + try: + raise main() + except Exception as e: + # Print full traceback error report if skills triggers an error from the call stack + if 'exceptions must derive from BaseException' not in str(e): + print_exc() diff --git a/server/src/core/nlu.js b/server/src/core/nlu.js index ea7401daa..481a8c86b 100644 --- a/server/src/core/nlu.js +++ b/server/src/core/nlu.js @@ -326,7 +326,11 @@ class Nlu { // When the active context has slots filled if (Object.keys(this.conv.activeContext.slots).length > 0) { - return resolve(await this.handleSlotFilling(utterance, opts)) + try { + return resolve(await this.handleSlotFilling(utterance, opts)) + } catch (e) { + return reject({ }) + } } } @@ -438,7 +442,11 @@ class Nlu { // In case all slots have been filled in the first utterance if (this.conv.hasActiveContext() && Object.keys(this.conv.activeContext.slots).length > 0) { - return resolve(await this.handleSlotFilling(utterance, opts)) + try { + return resolve(await this.handleSlotFilling(utterance, opts)) + } catch (e) { + return reject({ }) + } } const newContextName = `${this.nluResultObj.classification.domain}.${skillName}` diff --git a/skills/leon/introduction/nlu/en.json b/skills/leon/introduction/nlu/en.json index 141a8b24c..8834671ff 100644 --- a/skills/leon/introduction/nlu/en.json +++ b/skills/leon/introduction/nlu/en.json @@ -28,7 +28,7 @@ "name": "date" }, "questions": [ - "What's your birth date {{ person }}?" + "What's your birth date?" ] } ], diff --git a/skills/leon/introduction/src/actions/remember.py b/skills/leon/introduction/src/actions/remember.py index da7b8657e..e355d1a79 100644 --- a/skills/leon/introduction/src/actions/remember.py +++ b/skills/leon/introduction/src/actions/remember.py @@ -6,10 +6,10 @@ from random import randint def remember(params): - """Save name and birth date in Leon's memory""" + """Save name and birth date into Leon's memory""" slots = params['slots'] owner_name = slots['owner_name']['value']['resolution']['value'] - owner_birth_date = slots['owner_birthdate']['value']['resolution']['value'] + owner_birth_date = slots['owner_birth_date']['value']['resolution']['timex'] - return utils.output('end', 'default', utils.translate('default', { 'owner_name': owner_name })) + return utils.output('end', 'remembered', utils.translate('remembered', { 'owner_name': owner_name }))