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

Improve function invocation error #377

Merged
merged 7 commits into from
Feb 27, 2018
Merged

Improve function invocation error #377

merged 7 commits into from
Feb 27, 2018

Conversation

RaeesBhatti
Copy link
Contributor

No description provided.

@RaeesBhatti RaeesBhatti changed the title Fix a var name collision Improve function invocation error Feb 26, 2018
@@ -137,6 +137,10 @@ func (f *Function) callAWSLambda(payload []byte) ([]byte, error) {
if err != nil {
if awserr, ok := err.(awserr.Error); ok {
switch awserr.Code() {
case "AccessDeniedException":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elsteelbrain I did it differently, please take a look

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, of course.

return nil, &ErrFunctionError{err}
}
awslambda := lambda.New(awsSession)
awslambda := lambda.New(session.New(config))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is deprecated!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I will revert it


invokeOutput, err := awslambda.Invoke(&lambda.InvokeInput{
FunctionName: &f.Provider.ARN,
Payload: payload,
})
if err != nil {
if receivedAWSErr, ok := err.(awserr.Error); ok {
switch receivedAWSErr.Code() {
if awserr, ok := err.(awserr.Error); ok {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awserr collides with an imported package

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no automated check for that (with gometalinter) I would assume it's fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My linter is reporting a warning on this. Not that it would be problematic, just that it is bad practice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many places like that in the codebase. We can fix it but in separate PR, and it has to be automatically checked by gometalinter. AFAIR there is a check for that in gometalinter. Because of some reason, it has been turned off.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mthenw mthenw merged commit 5b51ea0 into master Feb 27, 2018
@mthenw mthenw deleted the improveInvokationError branch February 27, 2018 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants