Skip to content

Commit

Permalink
fix: ErrForeignKeyViolated error constant (#155)
Browse files Browse the repository at this point in the history
* fix: ErrForeignKeyViolated error constant

* refactor: added error codes reference

---------

Co-authored-by: Saeid Saeidee <s.saeidee@sensysgatso.com>
  • Loading branch information
saeidee and Saeid Saeidee committed Jun 9, 2023
1 parent 2a60d4f commit cf6cd11
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion error_translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"gorm.io/gorm"
)

// The error codes to map sqlite errors to gorm errors, here is a reference about error codes for sqlite https://www.sqlite.org/rescode.html.
var errCodes = map[int]error{
1555: gorm.ErrDuplicatedKey,
2067: gorm.ErrDuplicatedKey,
768: gorm.ErrForeignKeyViolated,
787: gorm.ErrForeignKeyViolated,
}

type ErrMessage struct {
Expand Down

0 comments on commit cf6cd11

Please sign in to comment.