mirror of
https://github.com/absmach/supermq.git
synced 2026-06-23 06:30:22 +00:00
67180a55f7
* update MG errors Signed-off-by: Arvindh <arvindh91@gmail.com> * update MG errors Signed-off-by: Arvindh <arvindh91@gmail.com> * sync with supermq main Signed-off-by: Arvindh <arvindh91@gmail.com> * update MG errors Signed-off-by: Arvindh <arvindh91@gmail.com> --------- Signed-off-by: Arvindh <arvindh91@gmail.com>
28 lines
594 B
Go
28 lines
594 B
Go
// Copyright (c) Abstract Machines
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package postgres
|
|
|
|
import (
|
|
"github.com/absmach/supermq/pkg/errors"
|
|
repoerr "github.com/absmach/supermq/pkg/errors/repository"
|
|
)
|
|
|
|
var _ errors.Mapper = (*duplicateErrors)(nil)
|
|
|
|
type duplicateErrors struct{}
|
|
|
|
// GetError maps constraint names to known errors.
|
|
func (d duplicateErrors) GetError(constraint string) (error, bool) {
|
|
switch constraint {
|
|
case "report_config_pkey":
|
|
return repoerr.ErrConflict, true
|
|
default:
|
|
return nil, false
|
|
}
|
|
}
|
|
|
|
func NewDuplicateErrors() errors.Mapper {
|
|
return duplicateErrors{}
|
|
}
|