-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(apigateway): throw ValidationError
instead of untyped errors
#33075
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import { Method } from './method'; | |
import { IVpcLink, VpcLink } from './vpc-link'; | ||
import * as iam from '../../aws-iam'; | ||
import { Lazy, Duration } from '../../core'; | ||
import { UnscopedValidationError } from '../../core/lib/errors'; | ||
|
||
export interface IntegrationOptions { | ||
/** | ||
|
@@ -199,23 +200,23 @@ export class Integration { | |
constructor(private readonly props: IntegrationProps) { | ||
const options = this.props.options || { }; | ||
if (options.credentialsPassthrough !== undefined && options.credentialsRole !== undefined) { | ||
throw new Error('\'credentialsPassthrough\' and \'credentialsRole\' are mutually exclusive'); | ||
throw new UnscopedValidationError('\'credentialsPassthrough\' and \'credentialsRole\' are mutually exclusive'); | ||
} | ||
|
||
if (options.connectionType === ConnectionType.VPC_LINK && options.vpcLink === undefined) { | ||
throw new Error('\'connectionType\' of VPC_LINK requires \'vpcLink\' prop to be set'); | ||
throw new UnscopedValidationError('\'connectionType\' of VPC_LINK requires \'vpcLink\' prop to be set'); | ||
} | ||
|
||
if (options.connectionType === ConnectionType.INTERNET && options.vpcLink !== undefined) { | ||
throw new Error('cannot set \'vpcLink\' where \'connectionType\' is INTERNET'); | ||
throw new UnscopedValidationError('cannot set \'vpcLink\' where \'connectionType\' is INTERNET'); | ||
} | ||
|
||
if (options.timeout && !options.timeout.isUnresolved() && options.timeout.toMilliseconds() < 50) { | ||
throw new Error('Integration timeout must be greater than 50 milliseconds.'); | ||
throw new UnscopedValidationError('Integration timeout must be greater than 50 milliseconds.'); | ||
} | ||
|
||
if (props.type !== IntegrationType.MOCK && !props.integrationHttpMethod) { | ||
throw new Error('integrationHttpMethod is required for non-mock integration types.'); | ||
throw new UnscopedValidationError('integrationHttpMethod is required for non-mock integration types.'); | ||
} | ||
} | ||
|
||
|
@@ -235,12 +236,12 @@ export class Integration { | |
if (vpcLink instanceof VpcLink) { | ||
const targets = vpcLink._targetDnsNames; | ||
if (targets.length > 1) { | ||
throw new Error("'uri' is required when there are more than one NLBs in the VPC Link"); | ||
throw new UnscopedValidationError("'uri' is required when there are more than one NLBs in the VPC Link"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be scoped to |
||
} else { | ||
return `http://${targets[0]}`; | ||
} | ||
} else { | ||
throw new Error("'uri' is required when the 'connectionType' is VPC_LINK"); | ||
throw new UnscopedValidationError("'uri' is required when the 'connectionType' is VPC_LINK"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. feels like here too |
||
} | ||
}, | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { AwsIntegration } from './aws'; | |
import * as iam from '../../../aws-iam'; | ||
import * as sfn from '../../../aws-stepfunctions'; | ||
import { Token } from '../../../core'; | ||
import { UnscopedValidationError } from '../../../core/lib/errors'; | ||
import { IntegrationConfig, IntegrationOptions, PassthroughBehavior } from '../integration'; | ||
import { Method } from '../method'; | ||
import { Model } from '../model'; | ||
|
@@ -150,7 +151,7 @@ class StepFunctionsExecutionIntegration extends AwsIntegration { | |
if (this.stateMachine instanceof sfn.StateMachine) { | ||
const stateMachineType = (this.stateMachine as sfn.StateMachine).stateMachineType; | ||
if (stateMachineType !== sfn.StateMachineType.EXPRESS) { | ||
throw new Error('State Machine must be of type "EXPRESS". Please use StateMachineType.EXPRESS as the stateMachineType'); | ||
throw new UnscopedValidationError('State Machine must be of type "EXPRESS". Please use StateMachineType.EXPRESS as the stateMachineType'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this.stateMachine? |
||
} | ||
|
||
//if not imported, extract the name from the CFN layer to reach the | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why can't this be scoped to
this
?