Skip to content

Commit

Permalink
added LUIS error handling (#1949)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrichardson authored Mar 26, 2020
1 parent 9befacb commit 9125adf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libraries/botbuilder-ai/src/luisRecognizerOptionsV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ export class LuisRecognizerV3 extends LuisRecognizerInternal {
const uri = this.buildUrl();
const httpOptions = this.buildRequestBody(utterance);

const data = await fetch(uri, httpOptions)
const data = await fetch(uri, httpOptions);
const response = await data.json();
if (response.error) {
const errObj = response.error;
const errMessage = errObj.code ? `${ errObj.code }: ${ errObj.message }` : errObj.message;
throw new Error(`[LUIS Recognition Error]: ${ errMessage }`);
}
const result: RecognizerResult = {
text: utterance,
intents : getIntents(response.prediction),
Expand Down

0 comments on commit 9125adf

Please sign in to comment.