From b7c3e058e9b161065b9024458fc7be0b3c5e8cb5 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sat, 10 Apr 2021 20:11:35 +0200 Subject: Implemented a user table and the CreateUser function --- pkg/database/error.go | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'pkg/database/error.go') diff --git a/pkg/database/error.go b/pkg/database/error.go index 1681dd5..0c19752 100644 --- a/pkg/database/error.go +++ b/pkg/database/error.go @@ -38,6 +38,40 @@ func newMigrationError(version int, err error) error { } } +// Password hash error +type PasswordError struct { + err error +} + +func (e *PasswordError) Error() string { + return fmt.Sprintf("Failed to hash password : %+v", e.err) +} +func (e *PasswordError) Unwrap() error { return e.err } + +func newPasswordError(err error) error { + return &PasswordError{ + err: err, + } +} + +// database query error +type QueryError struct { + msg string + err error +} + +func (e *QueryError) Error() string { + return fmt.Sprintf("Failed to perform query : %s", e.msg) +} +func (e *QueryError) Unwrap() error { return e.err } + +func newQueryError(msg string, err error) error { + return &QueryError{ + msg: msg, + err: err, + } +} + // database transaction error type TransactionError struct { msg string @@ -45,7 +79,7 @@ type TransactionError struct { } func (e *TransactionError) Error() string { - return fmt.Sprintf("Failed to perform transaction : %s", e.msg) + return fmt.Sprintf("Failed to perform query : %s", e.msg) } func (e *TransactionError) Unwrap() error { return e.err } -- cgit v1.2.3