From d0097fd3fee6fee1c8f87c77c418ebb7a6924f11 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Fri, 7 Jan 2022 13:18:22 -0800 Subject: [PATCH] executor: prevent a nasty error message if an HTTP error bubbles up --- lib/dialogue-agent/statement_executor.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/dialogue-agent/statement_executor.ts b/lib/dialogue-agent/statement_executor.ts index e64fbe69b..66e986b29 100644 --- a/lib/dialogue-agent/statement_executor.ts +++ b/lib/dialogue-agent/statement_executor.ts @@ -37,7 +37,7 @@ const MORE_SIZE = 50; const PAGE_SIZE = 10; interface ErrorWithCode extends Error { - code ?: string; + code ?: unknown; } /** @@ -172,7 +172,9 @@ export default class InferenceStatementExecutor { const annotations : Ast.AnnotationMap = {}; let errorValue; if (error) { - if (error.code) + if (typeof error.code === 'number') + errorValue = new Ast.Value.Enum(`http_${error.code}`); + else if (typeof error.code === 'string' && error.code) errorValue = new Ast.Value.Enum(error.code); else errorValue = new Ast.Value.String(error.message);