Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
uvulpos committed Aug 29, 2024
1 parent c428fdf commit 01de14b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
12 changes: 10 additions & 2 deletions services/backend/src/helper/customerrors/err_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type DatabaseError struct {
}

func NewDatabaseError(err error, userID string, errorContextData string, sqlQuery string, sqlData SqlData) *DatabaseError {
return &DatabaseError{
model := &DatabaseError{
ID: uuid.New().String(),

errorIdentifier: errorconst.ERROR_IDENTIFIER_DATABASE,
Expand All @@ -41,6 +41,10 @@ func NewDatabaseError(err error, userID string, errorContextData string, sqlQuer

error: err,
}

fmt.Printf("🚨 %s\n", model.GetDeveloperMessage())

return model
}

func (e *DatabaseError) Error() string {
Expand All @@ -53,7 +57,7 @@ func (e *DatabaseError) ErrorType() (errorIdentifier errorconst.ErrorIdentifier)

func (e *DatabaseError) HttpError() (int, errorconst.ErrorIdentifier, string) {
if debugMode {
errormessage := fmt.Sprintf("[%s] #%s <br> %s <br> %s", e.errorIdentifier, e.ID, e.httpUserMessage, e.error.Error())
errormessage := e.GetDeveloperMessage()
return e.httpStatus, e.errorIdentifier, errormessage
}
return e.httpStatus, e.errorIdentifier, e.httpUserMessage
Expand All @@ -68,3 +72,7 @@ func (e *DatabaseError) LoggerError() (time.Time, int, errorconst.ErrorIdentifie
)
return time.Now(), e.httpStatus, e.errorIdentifier, e.requestingUserID, contextData, e.error.Error()
}

func (e *DatabaseError) GetDeveloperMessage() string {
return fmt.Sprintf("[%s] #%s <br> %s <br> %s", e.errorIdentifier, e.ID, e.httpUserMessage, e.error.Error())
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type DatabaseNotFoundError struct {
}

func NewDatabaseNotFoundError(err error, userID string, sqlQuery string, sqlData SqlData) *DatabaseNotFoundError {
return &DatabaseNotFoundError{
model := &DatabaseNotFoundError{
ID: uuid.New().String(),

errorIdentifier: errorconst.ERROR_IDENTIFIER_DATABASE_NOT_FOUND,
Expand All @@ -39,6 +39,9 @@ func NewDatabaseNotFoundError(err error, userID string, sqlQuery string, sqlData

error: err,
}
fmt.Printf("🚨 %s\n", model.GetDeveloperMessage())

return model
}

func (e *DatabaseNotFoundError) Error() string {
Expand All @@ -51,7 +54,7 @@ func (e *DatabaseNotFoundError) ErrorType() (errorIdentifier errorconst.ErrorIde

func (e *DatabaseNotFoundError) HttpError() (int, errorconst.ErrorIdentifier, string) {
if debugMode {
errormessage := fmt.Sprintf("[%s] #%s <br> %s <br> %s", e.errorIdentifier, e.ID, e.httpUserMessage, e.error.Error())
errormessage := e.GetDeveloperMessage()
return e.httpStatus, e.errorIdentifier, errormessage
}
return e.httpStatus, e.errorIdentifier, e.httpUserMessage
Expand All @@ -65,3 +68,7 @@ func (e *DatabaseNotFoundError) LoggerError() (time.Time, int, errorconst.ErrorI
)
return time.Now(), e.httpStatus, e.errorIdentifier, e.requestingUserID, contextData, e.error.Error()
}

func (e *DatabaseNotFoundError) GetDeveloperMessage() string {
return fmt.Sprintf("[%s] #%s <br> %s <br> %s", e.errorIdentifier, e.ID, e.httpUserMessage, e.error.Error())
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type DatabaseTransactionBeginError struct {
}

func NewDatabaseTransactionBeginError(err error, errorContextData string) *DatabaseTransactionBeginError {
return &DatabaseTransactionBeginError{
model := &DatabaseTransactionBeginError{
ID: uuid.New().String(),

errorIdentifier: errorconst.ERROR_IDENTIFIER_DATABASE_TRANSACTION_NOT_STARTED,
Expand All @@ -33,6 +33,10 @@ func NewDatabaseTransactionBeginError(err error, errorContextData string) *Datab

error: err,
}

fmt.Printf("🚨 %s\n", model.GetDeveloperMessage())

return model
}

func (e *DatabaseTransactionBeginError) Error() string {
Expand All @@ -45,7 +49,7 @@ func (e *DatabaseTransactionBeginError) ErrorType() (errorIdentifier errorconst.

func (e *DatabaseTransactionBeginError) HttpError() (int, errorconst.ErrorIdentifier, string) {
if debugMode {
errormessage := fmt.Sprintf("[%s] #%s <br> %s <br> %s", e.errorIdentifier, e.ID, e.httpUserMessage, e.error.Error())
errormessage := e.GetDeveloperMessage()
return e.httpStatus, e.errorIdentifier, errormessage
}
return e.httpStatus, e.errorIdentifier, e.httpUserMessage
Expand All @@ -54,3 +58,7 @@ func (e *DatabaseTransactionBeginError) HttpError() (int, errorconst.ErrorIdenti
func (e *DatabaseTransactionBeginError) LoggerError() (time.Time, int, errorconst.ErrorIdentifier, string, string, string) {
return time.Now(), e.httpStatus, e.errorIdentifier, "", "", e.error.Error()
}

func (e *DatabaseTransactionBeginError) GetDeveloperMessage() string {
return fmt.Sprintf("[%s] #%s <br> %s <br> %s", e.errorIdentifier, e.ID, e.httpUserMessage, e.error.Error())
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type DatabaseTransactionCommitError struct {
}

func NewDatabaseTransactionCommitError(err error, errorContextData string) *DatabaseTransactionCommitError {
return &DatabaseTransactionCommitError{
model := &DatabaseTransactionCommitError{
ID: uuid.New().String(),

errorIdentifier: errorconst.ERROR_IDENTIFIER_DATABASE_TRANSACTION_NOT_STARTED,
Expand All @@ -33,6 +33,10 @@ func NewDatabaseTransactionCommitError(err error, errorContextData string) *Data

error: err,
}

fmt.Printf("🚨 %s\n", model.GetDeveloperMessage())

return model
}

func (e *DatabaseTransactionCommitError) Error() string {
Expand All @@ -45,7 +49,7 @@ func (e *DatabaseTransactionCommitError) ErrorType() (errorIdentifier errorconst

func (e *DatabaseTransactionCommitError) HttpError() (int, errorconst.ErrorIdentifier, string) {
if debugMode {
errormessage := fmt.Sprintf("[%s] #%s <br> %s <br> %s", e.errorIdentifier, e.ID, e.httpUserMessage, e.error.Error())
errormessage := e.GetDeveloperMessage()
return e.httpStatus, e.errorIdentifier, errormessage
}
return e.httpStatus, e.errorIdentifier, e.httpUserMessage
Expand All @@ -54,3 +58,7 @@ func (e *DatabaseTransactionCommitError) HttpError() (int, errorconst.ErrorIdent
func (e *DatabaseTransactionCommitError) LoggerError() (time.Time, int, errorconst.ErrorIdentifier, string, string, string) {
return time.Now(), e.httpStatus, e.errorIdentifier, "", "", e.error.Error()
}

func (e *DatabaseTransactionCommitError) GetDeveloperMessage() string {
return fmt.Sprintf("[%s] #%s <br> %s <br> %s", e.errorIdentifier, e.ID, e.httpUserMessage, e.error.Error())
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func NewInternalServerError(err error, userID string, errorContextData string) *
error: err,
}

fmt.Println("🚨")
fmt.Printf("🚨 %s\n", model.GetDeveloperMessage())

return model
}
Expand All @@ -53,7 +53,7 @@ func (e *InternalServerError) ErrorType() (errorIdentifier errorconst.ErrorIdent

func (e *InternalServerError) HttpError() (int, errorconst.ErrorIdentifier, string) {
if debugMode {
errormessage := fmt.Sprintf("[%s] #%s <br> %s <br> %s", e.errorIdentifier, e.ID, e.httpUserMessage, e.error.Error())
errormessage := e.GetDeveloperMessage()
return e.httpStatus, e.errorIdentifier, errormessage
}
return e.httpStatus, e.errorIdentifier, e.httpUserMessage
Expand All @@ -62,3 +62,7 @@ func (e *InternalServerError) HttpError() (int, errorconst.ErrorIdentifier, stri
func (e *InternalServerError) LoggerError() (time.Time, int, errorconst.ErrorIdentifier, string, string, string) {
return time.Now(), e.httpStatus, e.errorIdentifier, e.requestingUserID, e.errorContextData, e.error.Error()
}

func (e *InternalServerError) GetDeveloperMessage() string {
return fmt.Sprintf("[%s] #%s <br> %s <br> %s", e.errorIdentifier, e.ID, e.httpUserMessage, e.error.Error())
}

0 comments on commit 01de14b

Please sign in to comment.