github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/pkg/persistence/errors.go (about)

     1  package persistence
     2  
     3  import (
     4  	"github.com/lib/pq"
     5  )
     6  
     7  // IsConstraintViolation missing godoc
     8  func IsConstraintViolation(err error) bool {
     9  	if err == nil {
    10  		return false
    11  	}
    12  
    13  	if pqerr, ok := err.(*pq.Error); ok {
    14  		if pqerr.Code.Class() == ConstraintViolation {
    15  			return true
    16  		}
    17  	}
    18  	return false
    19  }