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

Implemented no-amplify-errors on additional packages #1976

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/old-bees-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@aws-amplify/schema-generator': patch
'@aws-amplify/model-generator': patch
---

added exceptions for reasonable violations of no-amplify-errors rule
10 changes: 9 additions & 1 deletion packages/eslint-rules/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ export const configs = {
},
},
{
files: ['packages/auth-construct/src/**'],
files: [
'packages/auth-construct/src/**',
'packages/ai-constructs/src/**',
'packages/backend-output-storage/src/**',
'packages/deployed-backend-client/src/**',
'packages/form-generator/src/**',
'packages/model-generator/src/**',
'packages/schema-generator/src/**',
],
rules: {
'amplify-backend-rules/no-amplify-errors': 'error',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const getBackendOutputWithErrorHandling = async (
error instanceof BackendOutputClientError &&
error.code === BackendOutputClientErrorType.DEPLOYMENT_IN_PROGRESS
) {
// eslint-disable-next-line amplify-backend-rules/no-amplify-errors
throw new AmplifyUserError(
'DeploymentInProgressError',
{
Expand All @@ -33,6 +34,7 @@ export const getBackendOutputWithErrorHandling = async (
error instanceof BackendOutputClientError &&
error.code === BackendOutputClientErrorType.NO_STACK_FOUND
) {
// eslint-disable-next-line amplify-backend-rules/no-amplify-errors
throw new AmplifyUserError(
'StackDoesNotExistError',
{
Expand All @@ -47,6 +49,7 @@ export const getBackendOutputWithErrorHandling = async (
error instanceof BackendOutputClientError &&
error.code === BackendOutputClientErrorType.CREDENTIALS_ERROR
) {
// eslint-disable-next-line amplify-backend-rules/no-amplify-errors
throw new AmplifyUserError(
'CredentialsError',
{
Expand All @@ -61,6 +64,7 @@ export const getBackendOutputWithErrorHandling = async (
error instanceof BackendOutputClientError &&
error.code === BackendOutputClientErrorType.ACCESS_DENIED
) {
// eslint-disable-next-line amplify-backend-rules/no-amplify-errors
throw new AmplifyUserError(
'AccessDeniedError',
{
Expand Down
3 changes: 3 additions & 0 deletions packages/schema-generator/src/generate_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class SchemaGenerator {
} catch (err) {
const databaseError = err as DatabaseConnectError;
if (databaseError.code === 'ETIMEDOUT') {
// eslint-disable-next-line amplify-backend-rules/no-amplify-errors
throw new AmplifyUserError<AmplifyGenerateSchemaError>(
'DatabaseConnectionError',
{
Expand Down Expand Up @@ -117,6 +118,7 @@ export const parseDatabaseUrl = (databaseUrl: string): SQLDataSourceConfig => {
).filter((part) => !config[part]);

if (missingParts.length > 0) {
// eslint-disable-next-line amplify-backend-rules/no-amplify-errors
throw new AmplifyUserError<AmplifyGenerateSchemaError>(
'DatabaseUrlParseError',
{
Expand All @@ -132,6 +134,7 @@ export const parseDatabaseUrl = (databaseUrl: string): SQLDataSourceConfig => {
return config;
} catch (err) {
const error = err as Error;
// eslint-disable-next-line amplify-backend-rules/no-amplify-errors
throw new AmplifyUserError<AmplifyGenerateSchemaError>(
'DatabaseUrlParseError',
{
Expand Down
Loading