diff --git a/packages/amplify-cli/src/extensions/amplify-helpers/trigger-flow.ts b/packages/amplify-cli/src/extensions/amplify-helpers/trigger-flow.ts index 519122431f0..bad0df6cce1 100644 --- a/packages/amplify-cli/src/extensions/amplify-helpers/trigger-flow.ts +++ b/packages/amplify-cli/src/extensions/amplify-helpers/trigger-flow.ts @@ -3,7 +3,7 @@ import chalk from 'chalk'; import * as fs from 'fs-extra'; import * as path from 'path'; import _ from 'lodash'; -import { JSONUtilities, $TSAny } from 'amplify-cli-core'; +import { exitOnNextTick, JSONUtilities, $TSAny } from 'amplify-cli-core'; import Separator from 'inquirer/lib/objects/separator'; // keep in sync with ServiceName in amplify-category-function, but probably it will not change @@ -193,10 +193,12 @@ export const updateTrigger = async triggerOptions => { await cleanFunctions(key, values, category, context, targetPath); } - context.print.success('Successfully updated the Lambda function locally'); + context.print.success('Successfully updated the Cognito trigger locally'); return null; - } catch (e) { - throw new Error('Unable to update lambda function'); + } catch (err: $TSAny) { + context.print.error(`Error updating the Cognito trigger: ${err.message}`); + await context.usageData.emitError(err); + exitOnNextTick(1); } };