Skip to content

Commit

Permalink
fix: remove duplicate error messages (#8651)
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardfoyle committed Nov 4, 2021
1 parent cead88d commit aad5de7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
9 changes: 5 additions & 4 deletions packages/amplify-category-api/src/commands/api/update.js
@@ -1,3 +1,5 @@
const { printer } = require('amplify-prompts');

const subcommand = 'update';
const category = 'api';

Expand All @@ -13,15 +15,14 @@ module.exports = {
.then(result => {
const providerController = require(`../../provider-utils/${result.providerName}/index`);
if (!providerController) {
context.print.error('Provider not configured for this category');
printer.error('Provider not configured for this category');
return;
}
return providerController.updateResource(context, category, result.service);
})
.then(() => context.print.success('Successfully updated resource'))
.then(() => printer.success('Successfully updated resource'))
.catch(err => {
context.print.error(err.message);
console.log(err.stack);
printer.error(err.message || err);
context.usageData.emitError(err);
process.exitCode = 1;
});
Expand Down
3 changes: 2 additions & 1 deletion packages/amplify-cli/src/commands/push.ts
Expand Up @@ -2,6 +2,7 @@ import sequential from 'promise-sequential';
import ora from 'ora';
import { $TSAny, $TSContext, $TSObject, stateManager, exitOnNextTick, ConfigurationError } from 'amplify-cli-core';
import { getProviderPlugins } from '../extensions/amplify-helpers/get-provider-plugins';
import { printer } from 'amplify-prompts';

const spinner = ora('');

Expand Down Expand Up @@ -64,7 +65,7 @@ export const run = async (context: $TSContext) => {
} catch (e) {
if (e.name !== 'InvalidDirectiveError') {
const message = e.name === 'GraphQLError' ? e.toString() : e.message;
context.print.error(`An error occurred during the push operation: ${message}`);
printer.error(`An error occurred during the push operation: ${message}`);
}
await context.usageData.emitError(e);
exitOnNextTick(1);
Expand Down
Expand Up @@ -4,14 +4,7 @@ import { onCategoryOutputsChange } from './on-category-outputs-change';
import { initializeEnv } from '../../initialize-env';
import { getProviderPlugins } from './get-provider-plugins';
import { getEnvInfo } from './get-env-info';
import {
EnvironmentDoesNotExistError,
exitOnNextTick,
stateManager,
$TSAny,
$TSContext,
} from 'amplify-cli-core';
import { printer } from 'amplify-prompts';
import { EnvironmentDoesNotExistError, exitOnNextTick, stateManager, $TSAny, $TSContext } from 'amplify-cli-core';

export async function pushResources(
context: $TSContext,
Expand Down Expand Up @@ -95,9 +88,6 @@ export async function pushResources(
retryPush = await handleValidGraphQLAuthError(context, err.message);
}
if (!retryPush) {
// Handle the errors and print them nicely for the user.
printer.blankLine();
printer.error(err.message);
throw err;
}
}
Expand Down

0 comments on commit aad5de7

Please sign in to comment.