error.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2015 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import (
  6. "errors"
  7. "fmt"
  8. )
  9. var (
  10. // ErrParamsType params error
  11. ErrParamsType = errors.New("Params type error")
  12. ErrParamsFormat = errors.New("Params format error")
  13. // ErrTableNotFound table not found error
  14. ErrTableNotFound = errors.New("Table not found")
  15. // ErrUnSupportedType unsupported error
  16. ErrUnSupportedType = errors.New("Unsupported type error")
  17. // ErrNotExist record does not exist error
  18. ErrNotExist = errors.New("Record does not exist")
  19. ErrNotInTransaction = errors.New("Not in transaction.")
  20. ErrNestedTransaction = errors.New("Nested transaction error.")
  21. ErrTransactionDefinition = errors.New("Transaction definition error.")
  22. // ErrCacheFailed cache failed error
  23. ErrCacheFailed = errors.New("Cache failed")
  24. // ErrNeedDeletedCond delete needs less one condition error
  25. ErrNeedDeletedCond = errors.New("Delete action needs at least one condition")
  26. // ErrNotImplemented not implemented
  27. ErrNotImplemented = errors.New("Not implemented")
  28. // ErrConditionType condition type unsupported
  29. ErrConditionType = errors.New("Unsupported condition type")
  30. )
  31. // ErrFieldIsNotExist columns does not exist
  32. type ErrFieldIsNotExist struct {
  33. FieldName string
  34. TableName string
  35. }
  36. func (e ErrFieldIsNotExist) Error() string {
  37. return fmt.Sprintf("field %s is not valid on table %s", e.FieldName, e.TableName)
  38. }
  39. // ErrFieldIsNotValid is not valid
  40. type ErrFieldIsNotValid struct {
  41. FieldName string
  42. TableName string
  43. }
  44. func (e ErrFieldIsNotValid) Error() string {
  45. return fmt.Sprintf("field %s is not valid on table %s", e.FieldName, e.TableName)
  46. }