mirror of
https://github.com/nabbar/golib.git
synced 2025-10-19 06:04:48 +08:00
Optimize errors for package aws & logger
Bump dependancies
This commit is contained in:
@@ -26,11 +26,11 @@
|
||||
package configAws
|
||||
|
||||
import (
|
||||
"github.com/nabbar/golib/errors"
|
||||
liberr "github.com/nabbar/golib/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
ErrorAwsError errors.CodeError = iota + errors.MinPkgAws + 40
|
||||
ErrorAwsError liberr.CodeError = iota + liberr.MinPkgAws + 40
|
||||
ErrorConfigLoader
|
||||
ErrorConfigValidator
|
||||
ErrorConfigJsonUnmarshall
|
||||
@@ -40,21 +40,18 @@ const (
|
||||
ErrorCredentialsInvalid
|
||||
)
|
||||
|
||||
var isErrInit = false
|
||||
var isErrInit = liberr.ExistInMapMessage(ErrorAwsError)
|
||||
|
||||
func init() {
|
||||
errors.RegisterIdFctMessage(ErrorAwsError, getMessage)
|
||||
isErrInit = errors.ExistInMapMessage(ErrorAwsError)
|
||||
liberr.RegisterIdFctMessage(ErrorAwsError, getMessage)
|
||||
}
|
||||
|
||||
func IsErrorInit() bool {
|
||||
return isErrInit
|
||||
}
|
||||
|
||||
func getMessage(code errors.CodeError) string {
|
||||
func getMessage(code liberr.CodeError) string {
|
||||
switch code {
|
||||
case errors.UNK_ERROR:
|
||||
return ""
|
||||
case ErrorAwsError:
|
||||
return "calling aws api occurred a response error"
|
||||
case ErrorConfigLoader:
|
||||
@@ -73,5 +70,5 @@ func getMessage(code errors.CodeError) string {
|
||||
return "the specified credentials seems to be incorrect"
|
||||
}
|
||||
|
||||
return ""
|
||||
return liberr.UNK_MESSAGE
|
||||
}
|
||||
|
@@ -26,11 +26,11 @@
|
||||
package configCustom
|
||||
|
||||
import (
|
||||
"github.com/nabbar/golib/errors"
|
||||
liberr "github.com/nabbar/golib/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
ErrorAwsError errors.CodeError = iota + errors.MinPkgAws + 20
|
||||
ErrorAwsError liberr.CodeError = iota + liberr.MinPkgAws + 20
|
||||
ErrorConfigValidator
|
||||
ErrorConfigJsonUnmarshall
|
||||
ErrorEndpointInvalid
|
||||
@@ -39,21 +39,18 @@ const (
|
||||
ErrorCredentialsInvalid
|
||||
)
|
||||
|
||||
var isErrInit = false
|
||||
var isErrInit = liberr.ExistInMapMessage(ErrorAwsError)
|
||||
|
||||
func init() {
|
||||
errors.RegisterIdFctMessage(ErrorAwsError, getMessage)
|
||||
isErrInit = errors.ExistInMapMessage(ErrorAwsError)
|
||||
liberr.RegisterIdFctMessage(ErrorAwsError, getMessage)
|
||||
}
|
||||
|
||||
func IsErrorInit() bool {
|
||||
return isErrInit
|
||||
}
|
||||
|
||||
func getMessage(code errors.CodeError) string {
|
||||
func getMessage(code liberr.CodeError) string {
|
||||
switch code {
|
||||
case errors.UNK_ERROR:
|
||||
return ""
|
||||
case ErrorAwsError:
|
||||
return "calling aws api occurred a response error"
|
||||
case ErrorConfigValidator:
|
||||
@@ -70,5 +67,5 @@ func getMessage(code errors.CodeError) string {
|
||||
return "the specified credentials seems to be incorrect"
|
||||
}
|
||||
|
||||
return ""
|
||||
return liberr.UNK_MESSAGE
|
||||
}
|
||||
|
@@ -25,7 +25,9 @@
|
||||
|
||||
package helper
|
||||
|
||||
import "github.com/nabbar/golib/errors"
|
||||
import (
|
||||
errors "github.com/nabbar/golib/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
// minmal are errors.MIN_AVAILABLE + get a hope free range 1000 + 10 for aws-config errors.
|
||||
@@ -37,11 +39,10 @@ const (
|
||||
ErrorParamsEmpty
|
||||
)
|
||||
|
||||
var isErrInit = false
|
||||
var isErrInit = errors.ExistInMapMessage(ErrorResponse)
|
||||
|
||||
func init() {
|
||||
errors.RegisterIdFctMessage(ErrorResponse, getMessage)
|
||||
isErrInit = errors.ExistInMapMessage(ErrorResponse)
|
||||
}
|
||||
|
||||
func IsErrorInit() bool {
|
||||
@@ -50,8 +51,6 @@ func IsErrorInit() bool {
|
||||
|
||||
func getMessage(code errors.CodeError) string {
|
||||
switch code {
|
||||
case errors.UNK_ERROR:
|
||||
return ""
|
||||
case ErrorResponse:
|
||||
return "calling aws api occurred a response error"
|
||||
case ErrorConfigEmpty:
|
||||
@@ -66,5 +65,5 @@ func getMessage(code errors.CodeError) string {
|
||||
return "at least one parameters needed is empty"
|
||||
}
|
||||
|
||||
return ""
|
||||
return errors.UNK_MESSAGE
|
||||
}
|
||||
|
74
go.mod
74
go.mod
@@ -3,15 +3,15 @@ module github.com/nabbar/golib
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.2
|
||||
github.com/aws/aws-sdk-go-v2/config v1.15.3
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.11.2
|
||||
github.com/aws/aws-sdk-go-v2/service/iam v1.18.3
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.26.5
|
||||
github.com/aws/aws-sdk-go-v2 v1.16.3
|
||||
github.com/aws/aws-sdk-go-v2/config v1.15.4
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.12.0
|
||||
github.com/aws/aws-sdk-go-v2/service/iam v1.18.4
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.26.7
|
||||
github.com/bits-and-blooms/bitset v1.2.2
|
||||
github.com/c-bata/go-prompt v0.2.6
|
||||
github.com/fatih/color v1.13.0
|
||||
github.com/fsnotify/fsnotify v1.5.2
|
||||
github.com/fsnotify/fsnotify v1.5.4
|
||||
github.com/fxamacker/cbor/v2 v2.4.0
|
||||
github.com/gin-gonic/gin v1.7.7
|
||||
github.com/go-ldap/ldap/v3 v3.4.3
|
||||
@@ -22,16 +22,16 @@ require (
|
||||
github.com/hashicorp/go-uuid v1.0.3
|
||||
github.com/hashicorp/go-version v1.4.0
|
||||
github.com/jlaffaye/ftp v0.0.0-20220310202011-d2c44e311e78
|
||||
github.com/lni/dragonboat/v3 v3.1.1-0.20220408124445-68619d033a59
|
||||
github.com/lni/dragonboat/v3 v3.1.1-0.20220423051305-68cf0ad96f46
|
||||
github.com/matcornic/hermes/v2 v2.1.0
|
||||
github.com/mattn/go-colorable v0.1.12
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/nats-io/jwt/v2 v2.2.1-0.20220330180145-442af02fd36a
|
||||
github.com/nats-io/nats-server/v2 v2.8.0
|
||||
github.com/nats-io/nats-server/v2 v2.8.1
|
||||
github.com/nats-io/nats.go v1.14.0
|
||||
github.com/onsi/ginkgo/v2 v2.1.3
|
||||
github.com/onsi/ginkgo/v2 v2.1.4
|
||||
github.com/onsi/gomega v1.19.0
|
||||
github.com/pelletier/go-toml v1.9.4
|
||||
github.com/pelletier/go-toml v1.9.5
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/client_golang v1.12.1
|
||||
github.com/shirou/gopsutil v3.21.11+incompatible
|
||||
@@ -40,28 +40,28 @@ require (
|
||||
github.com/spf13/jwalterweatherman v1.1.0
|
||||
github.com/spf13/viper v1.11.0
|
||||
github.com/vbauerster/mpb/v5 v5.4.0
|
||||
github.com/xanzy/go-gitlab v0.63.0
|
||||
github.com/xanzy/go-gitlab v0.64.0
|
||||
github.com/xhit/go-simple-mail v2.2.2+incompatible
|
||||
github.com/xujiajun/nutsdb v0.8.0
|
||||
github.com/xujiajun/utils v0.0.0-20190123093513-8bf096c4f53b
|
||||
golang.org/x/net v0.0.0-20220420153159-1850ba15e1be
|
||||
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
|
||||
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad
|
||||
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150
|
||||
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gorm.io/driver/clickhouse v0.3.2
|
||||
gorm.io/driver/mysql v1.3.3
|
||||
gorm.io/driver/postgres v1.3.4
|
||||
gorm.io/driver/sqlite v1.3.1
|
||||
gorm.io/driver/postgres v1.3.5
|
||||
gorm.io/driver/sqlite v1.3.2
|
||||
gorm.io/driver/sqlserver v1.3.2
|
||||
gorm.io/gorm v1.23.4
|
||||
gorm.io/gorm v1.23.5
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Azure/go-ntlmssp v0.0.0-20211209120228-48547f28849e // indirect
|
||||
github.com/ClickHouse/clickhouse-go v1.5.4 // indirect
|
||||
github.com/DataDog/zstd v1.5.0 // indirect
|
||||
github.com/DataDog/zstd v1.5.2 // indirect
|
||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||
github.com/Masterminds/semver v1.5.0 // indirect
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
|
||||
@@ -71,19 +71,19 @@ require (
|
||||
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
|
||||
github.com/andybalholm/cascadia v1.3.1 // indirect
|
||||
github.com/aokoli/goutils v1.1.1 // indirect
|
||||
github.com/armon/go-metrics v0.3.10 // indirect
|
||||
github.com/armon/go-metrics v0.3.11 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.9 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.10 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.0 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.10 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.11 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.3 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.5 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sso v1.11.4 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/sts v1.16.4 // indirect
|
||||
github.com/aws/smithy-go v1.11.2 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bwmarrin/snowflake v0.3.0 // indirect
|
||||
@@ -91,7 +91,7 @@ require (
|
||||
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 // indirect
|
||||
github.com/cockroachdb/errors v1.9.0 // indirect
|
||||
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect
|
||||
github.com/cockroachdb/pebble v0.0.0-20220420164113-d8ca1fc6fddd // indirect
|
||||
github.com/cockroachdb/pebble v0.0.0-20220428002600-b9e970a83ddd // indirect
|
||||
github.com/cockroachdb/redact v1.1.3 // indirect
|
||||
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
|
||||
github.com/codahale/hdrhistogram v0.9.0 // indirect
|
||||
@@ -125,19 +125,19 @@ require (
|
||||
github.com/imdario/mergo v0.3.12 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgconn v1.11.0 // indirect
|
||||
github.com/jackc/pgconn v1.12.0 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgproto3/v2 v2.2.0 // indirect
|
||||
github.com/jackc/pgproto3/v2 v2.3.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
|
||||
github.com/jackc/pgtype v1.10.0 // indirect
|
||||
github.com/jackc/pgx/v4 v4.15.0 // indirect
|
||||
github.com/jackc/pgtype v1.11.0 // indirect
|
||||
github.com/jackc/pgx/v4 v4.16.0 // indirect
|
||||
github.com/jaytaylor/html2text v0.0.0-20211105163654-bc68cce691ba // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/juju/ratelimit v1.0.2-0.20191002062651-f60b32039441 // indirect
|
||||
github.com/klauspost/compress v1.15.1 // indirect
|
||||
github.com/klauspost/compress v1.15.2 // indirect
|
||||
github.com/kr/pretty v0.3.0 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
@@ -159,7 +159,7 @@ require (
|
||||
github.com/nats-io/nkeys v0.3.0 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.0 // indirect
|
||||
github.com/pkg/term v1.2.0-beta.2 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.34.0 // indirect
|
||||
@@ -181,8 +181,8 @@ require (
|
||||
github.com/x448/float16 v0.8.4 // indirect
|
||||
github.com/xujiajun/mmap-go v1.0.1 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.2 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
|
||||
golang.org/x/exp v0.0.0-20220414153411-bcd21879b8fd // indirect
|
||||
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f // indirect
|
||||
golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5 // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
|
||||
|
@@ -26,33 +26,32 @@
|
||||
|
||||
package logger
|
||||
|
||||
import "github.com/nabbar/golib/errors"
|
||||
import (
|
||||
liberr "github.com/nabbar/golib/errors"
|
||||
)
|
||||
|
||||
const (
|
||||
ErrorParamsEmpty errors.CodeError = iota + errors.MinPkgLogger
|
||||
ErrorParamsEmpty liberr.CodeError = iota + liberr.MinPkgLogger
|
||||
ErrorValidatorError
|
||||
)
|
||||
|
||||
var isCodeError = false
|
||||
var isCodeError = liberr.ExistInMapMessage(ErrorParamsEmpty)
|
||||
|
||||
func IsCodeError() bool {
|
||||
return isCodeError
|
||||
}
|
||||
|
||||
func init() {
|
||||
isCodeError = errors.ExistInMapMessage(ErrorParamsEmpty)
|
||||
errors.RegisterIdFctMessage(ErrorParamsEmpty, getMessage)
|
||||
liberr.RegisterIdFctMessage(ErrorParamsEmpty, getMessage)
|
||||
}
|
||||
|
||||
func getMessage(code errors.CodeError) (message string) {
|
||||
func getMessage(code liberr.CodeError) (message string) {
|
||||
switch code {
|
||||
case errors.UNK_ERROR:
|
||||
return ""
|
||||
case ErrorParamsEmpty:
|
||||
return "given parameters is empty"
|
||||
case ErrorValidatorError:
|
||||
return "logger : invalid config"
|
||||
}
|
||||
|
||||
return ""
|
||||
return liberr.UNK_MESSAGE
|
||||
}
|
||||
|
Reference in New Issue
Block a user