Skip to content

Commit

Permalink
Changing conection error message to avoid password exposure (#68)
Browse files Browse the repository at this point in the history
* Changing conection error message to avoid password exposure

Signed-off-by: Ian Cardoso <ian.cardoso@zup.com.br>

* Fix linter

Signed-off-by: Ian Cardoso <ian.cardoso@zup.com.br>
  • Loading branch information
iancardosozup authored Aug 20, 2021
1 parent 70a3499 commit 9dfc182
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/services/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (d *database) makeConnection() {
func (d *database) makeConnectionWrite() {
connectionWrite, err := gorm.Open(postgres.Open(d.config.GetURI()), &gorm.Config{})
if err != nil {
logger.LogPanic(enums.MessageFailedToConnectToDatabase, err)
logger.LogPanic(enums.MessageFailedToConnectToDatabase, enums.ErrorConnectingToDB)
}

d.connectionWrite = connectionWrite
Expand All @@ -76,7 +76,7 @@ func (d *database) makeConnectionWrite() {
func (d *database) makeConnectionRead() {
connectionRead, err := gorm.Open(postgres.Open(d.config.GetURI()), &gorm.Config{})
if err != nil {
logger.LogPanic(enums.MessageFailedToConnectToDatabase, err)
logger.LogPanic(enums.MessageFailedToConnectToDatabase, enums.ErrorConnectingToDB)
}

d.connectionRead = connectionRead
Expand Down
5 changes: 5 additions & 0 deletions pkg/services/database/enums/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ package enums
import "errors"

var ErrorNotFoundRecords = errors.New("{ERROR_DATABASE} database not found records")

//nolint
var ErrorConnectingToDB = errors.New("{ERROR_DATABASE} error connecting to db, use this format" +
" string for connection in " + EnvRelationalURI +
": 'host=localhost user=username password=user_password dbname=db_name port=5432 sslmode=disable TimeZone=Asia/Shanghai'")

0 comments on commit 9dfc182

Please sign in to comment.