pgerror.go 1.0 KB

1234567891011121314151617181920212223242526272829
  1. // Package pgerror holds SQLSTATE metadata and sentinel errors shared by the
  2. // parser, executor, and protocol servers.
  3. package pgerror
  4. import (
  5. "errors"
  6. "fmt"
  7. )
  8. // SQLSTATE codes used by PizzaSQL's protocol and HTTP surfaces.
  9. const (
  10. CodeFeatureNotSupported = "0A000"
  11. CodeUniqueViolation = "23505"
  12. CodeCheckViolation = "23514"
  13. CodeSerializationFailure = "40001"
  14. CodeSyntaxError = "42601"
  15. CodeInternalError = "XX000"
  16. )
  17. // ErrFeatureNotSupported marks SQL that PizzaSQL intentionally rejects instead
  18. // of accepting with different semantics. Protocol layers map it to SQLSTATE
  19. // 0A000 (feature_not_supported) rather than a generic syntax or internal error.
  20. var ErrFeatureNotSupported = errors.New("feature not supported")
  21. // Unsupported returns an error that wraps ErrFeatureNotSupported with a
  22. // client-facing explanation and migration hint.
  23. func Unsupported(format string, args ...interface{}) error {
  24. return fmt.Errorf("%w: %s", ErrFeatureNotSupported, fmt.Sprintf(format, args...))
  25. }