Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove duplicate error messages #8651

Merged
merged 1 commit into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/amplify-category-api/src/commands/api/update.js
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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