Skip to content

Commit

Permalink
Merge pull request #96 from getlift/better-error-message
Browse files Browse the repository at this point in the history
Improve error message for the most common user error
  • Loading branch information
mnapoli authored Sep 16, 2021
2 parents ddb1896 + 39e3820 commit 449d23b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/constructs/aws/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ export class Queue extends AwsConstruct {
) {
super(scope, id);

// This should be covered by the schema validation, but until it is enforced by default
// this is a very common error for users
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (configuration.worker === undefined) {
throw new ServerlessError(
`Invalid configuration in 'constructs.${this.id}': no 'worker' defined. Queue constructs require a 'worker' function to be defined.`,
"LIFT_INVALID_CONSTRUCT_CONFIGURATION"
);
}

// The default function timeout is 6 seconds in the Serverless Framework
const functionTimeout = configuration.worker.timeout ?? 6;

Expand Down

0 comments on commit 449d23b

Please sign in to comment.