Skip to content

Commit

Permalink
Implemented no-amplify-errors in packages where it should be active (#…
Browse files Browse the repository at this point in the history
…1973)

* ai-constructs is added to no-amplify-errors

* activated no-amplify-errors in multiple packages

* added changeset

* changeset updated

* removed changeset for schema-generator and model-generator

* adjusting changesets

---------

Co-authored-by: Vieltojarvi <[email protected]>
  • Loading branch information
ShadowCat567 and Vieltojarvi authored Sep 10, 2024
1 parent 05d98e2 commit c10f6fc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/happy-adults-think.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
---

activated no-amplify-errors, ignored lines with valid violations
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

0 comments on commit c10f6fc

Please sign in to comment.