Skip to content

Commit ff4a637

Browse files
committed
minor: renamed errors
* Renamed errors * Upgraded dependencies
1 parent 9fd52f7 commit ff4a637

File tree

12 files changed

+27
-23
lines changed

12 files changed

+27
-23
lines changed

cloud/gcloud/errors.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package gcloud
33
import "errors"
44

55
var (
6-
NilGoogleCredentialsError = errors.New("google credentials cannot be nil")
7-
NilTokenSourceError = errors.New("token source cannot be nil")
8-
FailedToLoadGoogleCredentialsError = errors.New("failed to load google credentials")
9-
FailedToCreateTokenSourceError = errors.New("failed to create token source")
6+
ErrNilGoogleCredentials = errors.New("google credentials cannot be nil")
7+
ErrNilTokenSource = errors.New("token source cannot be nil")
8+
ErrFailedToLoadGoogleCredentials = errors.New("failed to load google credentials")
9+
ErrFailedToCreateTokenSource = errors.New("failed to create token source")
1010
)

cloud/gcloud/loader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func LoadGoogleCredentials(ctx context.Context) (*google.Credentials, error) {
1313
credentials, err := google.FindDefaultCredentials(ctx)
1414
if err != nil {
15-
return nil, FailedToLoadGoogleCredentialsError
15+
return nil, ErrFailedToLoadGoogleCredentials
1616
}
1717
return credentials, nil
1818
}
@@ -23,7 +23,7 @@ func LoadServiceAccountCredentials(
2323
) (*oauth.TokenSource, error) {
2424
// Check if the credentials are nil
2525
if credentials == nil {
26-
return nil, NilGoogleCredentialsError
26+
return nil, ErrNilGoogleCredentials
2727
}
2828

2929
// Create a new token source
@@ -33,7 +33,7 @@ func LoadServiceAccountCredentials(
3333
option.WithCredentials(credentials),
3434
)
3535
if err != nil {
36-
return nil, FailedToCreateTokenSourceError
36+
return nil, ErrFailedToCreateTokenSource
3737
}
3838

3939
return &oauth.TokenSource{TokenSource: tokenSource}, nil

cloud/gcloud/logger.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ func NewLogger(logger gologger.Logger) (*Logger, error) {
2525
func (l *Logger) LoadedTokenSource(tokenSource *oauth.TokenSource) {
2626
// Check if the token source is nil
2727
if tokenSource == nil {
28-
l.logger.LogError(gologger.NewLogError("failed to load token source", nil, NilTokenSourceError))
28+
l.logger.LogError(gologger.NewLogError("failed to load token source", nil,
29+
ErrNilTokenSource
30+
))
2931
return
3032
}
3133

env/errors.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package env
33
import "errors"
44

55
var (
6-
EnvironmentVariableNotFoundError = "environment variable not found: %v"
7-
FailedToLoadEnvironmentVariablesError = errors.New("failed to load environment variables")
8-
InvalidDurationError = "invalid key '%v' duration value: %v"
6+
ErrEnvironmentVariableNotFound = "environment variable not found: %v"
7+
ErrFailedToLoadEnvironmentVariables = errors.New("failed to load environment variables")
8+
ErrInvalidDuration = "invalid key '%v' duration value: %v"
99
)

env/loader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func LoadVariable(key string) (uri string, err error) {
1111
// Get environment variable
1212
variable, exists := os.LookupEnv(key)
1313
if !exists {
14-
return "", fmt.Errorf(EnvironmentVariableNotFoundError, key)
14+
return "", fmt.Errorf(ErrEnvironmentVariableNotFound, key)
1515
}
1616
return variable, nil
1717
}
@@ -27,7 +27,7 @@ func LoadDurationVariable(key string) (duration time.Duration, err error) {
2727
// Parse the duration
2828
duration, err = time.ParseDuration(variable)
2929
if err != nil {
30-
return 0, fmt.Errorf(InvalidDurationError, key, variable)
30+
return 0, fmt.Errorf(ErrInvalidDuration, key, variable)
3131
}
3232
return duration, nil
3333
}

filesystem/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package filesystem
22

33
var (
4-
UnableToReadFileError = "unable to read file: %v"
4+
ErrUnableToReadFile = "unable to read file: %v"
55
)

filesystem/read_files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
func ReadFile(path string) ([]byte, error) {
1010
file, err := os.ReadFile(path)
1111
if err != nil {
12-
return nil, fmt.Errorf(UnableToReadFileError, err)
12+
return nil, fmt.Errorf(ErrUnableToReadFile, err)
1313
}
1414
return file, nil
1515
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/ralvarezdev/go-loader
33
go 1.23.4
44

55
require (
6-
github.com/ralvarezdev/go-logger v0.1.0
6+
github.com/ralvarezdev/go-logger v0.2.2
77
golang.org/x/oauth2 v0.24.0
88
google.golang.org/api v0.213.0
99
google.golang.org/grpc v1.69.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
2929
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3030
github.com/ralvarezdev/go-logger v0.1.0 h1:i2AI1nlxU6Hizvk75Vc8wtFydiVrqIeeRbJwiuO/69A=
3131
github.com/ralvarezdev/go-logger v0.1.0/go.mod h1:v5OvFrkS+wsYNTCVegXWiRhBtcYrQJr4LDMDntvpAos=
32+
github.com/ralvarezdev/go-logger v0.2.2 h1:j58spza2L6s+vAibifHSuUPrXm0+6nWZWR3SOg8ihBk=
33+
github.com/ralvarezdev/go-logger v0.2.2/go.mod h1:v5OvFrkS+wsYNTCVegXWiRhBtcYrQJr4LDMDntvpAos=
3234
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
3335
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
3436
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 h1:r6I7RJCN86bpD/FQwedZ0vSixDpwuWREjW9oRMsmqDc=

http/listener/errors.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package listener
33
import "errors"
44

55
var (
6-
FailedToCloseError = errors.New("failed to close listener")
7-
FailedToListenError = errors.New("failed to listen")
8-
FailedToServeError = errors.New("failed to serve")
6+
ErrFailedToClose = errors.New("failed to close listener")
7+
ErrFailedToListen = errors.New("failed to listen")
8+
ErrFailedToServe = errors.New("failed to serve")
99
)

0 commit comments

Comments
 (0)