Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Commits
cca23cda
Commit
cca23cda
authored
1 year ago
by
Daniel Naude
Browse files
Options
Downloads
Patches
Plain Diff
Improve error handling
parent
ae776050
No related branches found
No related tags found
1 merge request
!48
Migrate to aws sdk for go v2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
errors/errors.go
+4
-4
4 additions, 4 deletions
errors/errors.go
s3/s3.go
+4
-6
4 additions, 6 deletions
s3/s3.go
secrets_manager/secrets_manager.go
+2
-2
2 additions, 2 deletions
secrets_manager/secrets_manager.go
with
10 additions
and
12 deletions
errors/errors.go
+
4
−
4
View file @
cca23cda
...
@@ -129,9 +129,9 @@ func AWSErrorExceptionCode(err error) string {
...
@@ -129,9 +129,9 @@ func AWSErrorExceptionCode(err error) string {
return
""
return
""
}
}
var
apiErr
*
smithy
.
Generic
APIError
var
apiErr
smithy
.
APIError
if
errors
.
As
(
err
,
&
apiErr
)
{
if
errors
.
As
(
err
,
&
apiErr
)
{
return
apiErr
.
Code
return
apiErr
.
Error
Code
()
}
}
return
""
return
""
}
}
...
@@ -141,9 +141,9 @@ func AWSErrorWithoutExceptionCode(err error) error {
...
@@ -141,9 +141,9 @@ func AWSErrorWithoutExceptionCode(err error) error {
return
nil
return
nil
}
}
var
apiErr
*
smithy
.
Generic
APIError
var
apiErr
smithy
.
APIError
if
errors
.
As
(
err
,
&
apiErr
)
{
if
errors
.
As
(
err
,
&
apiErr
)
{
return
Error
(
apiErr
.
Message
)
return
Error
(
apiErr
.
Error
Message
()
)
}
}
return
err
return
err
}
}
...
...
This diff is collapsed.
Click to expand it.
s3/s3.go
+
4
−
6
View file @
cca23cda
...
@@ -13,7 +13,6 @@ import (
...
@@ -13,7 +13,6 @@ import (
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/smithy-go"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/secrets_manager"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/secrets_manager"
std_errors
"errors"
std_errors
"errors"
...
@@ -22,6 +21,7 @@ import (
...
@@ -22,6 +21,7 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/s3/types"
"github.com/google/uuid"
"github.com/google/uuid"
)
)
...
@@ -336,12 +336,10 @@ func (s ClientWithHelpers) FileExists(bucket string, fileName string) (bool, err
...
@@ -336,12 +336,10 @@ func (s ClientWithHelpers) FileExists(bucket string, fileName string) (bool, err
Key
:
aws
.
String
(
fileName
),
Key
:
aws
.
String
(
fileName
),
})
})
if
err
!=
nil
{
if
err
!=
nil
{
var
apiErr
*
smithy
.
GenericAPIError
var
notFoundErr
*
types
.
NotFound
if
std_errors
.
As
(
err
,
&
apiErr
)
{
if
std_errors
.
As
(
err
,
&
notFoundErr
)
{
if
apiErr
.
Code
==
"NotFound"
{
return
false
,
nil
return
false
,
nil
}
}
}
return
false
,
err
return
false
,
err
}
}
return
true
,
nil
return
true
,
nil
...
...
This diff is collapsed.
Click to expand it.
secrets_manager/secrets_manager.go
+
2
−
2
View file @
cca23cda
...
@@ -95,9 +95,9 @@ func instantiateSecretManagerClient(isDebug bool) (err error) {
...
@@ -95,9 +95,9 @@ func instantiateSecretManagerClient(isDebug bool) (err error) {
// logError Logs any errors returned by the Secrets Manager client
// logError Logs any errors returned by the Secrets Manager client
func
logError
(
err
error
)
{
func
logError
(
err
error
)
{
var
apiErr
*
smithy
.
Generic
APIError
var
apiErr
smithy
.
APIError
if
errors
.
As
(
err
,
&
apiErr
)
{
if
errors
.
As
(
err
,
&
apiErr
)
{
logs
.
Info
(
apiErr
.
Code
+
" %s"
,
apiErr
.
Message
)
logs
.
Info
(
apiErr
.
Error
Code
()
+
" %s"
,
apiErr
.
Error
Message
()
)
}
else
{
}
else
{
logs
.
Info
(
err
.
Error
())
logs
.
Info
(
err
.
Error
())
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment