Skip to content

Commit

Permalink
refactor: modify logic to remove throw statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanay Yogesh Shah committed Oct 15, 2024
1 parent 64f3c3a commit 028aba1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/amplify-migration-codegen-e2e/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ export function removeProperties(obj: Record<string, unknown>, propertiesToRemov
}

export function removeErrorThrows(content: string): string {
const errorRegex = /throw new Error\([^)]*\)/g;
return content.replace(errorRegex, '');
const lines = content.split('\n');
const result = lines.filter((line) => {
const trimmedLine = line.trim();
return !trimmedLine.startsWith('throw new Error(');
});
return result.join('\n');
}

0 comments on commit 028aba1

Please sign in to comment.