error.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // ErrPtrSliceType represents a type error
  11. ErrPtrSliceType = errors.New("A point to a slice is needed")
  12. // ErrParamsType params error
  13. ErrParamsType = errors.New("Params type error")
  14. ErrParamsFormat = errors.New("Params format error")
  15. // ErrTableNotFound table not found error
  16. ErrTableNotFound = errors.New("Table not found")
  17. // ErrUnSupportedType unsupported error
  18. ErrUnSupportedType = errors.New("Unsupported type error")
  19. // ErrNotExist record does not exist error
  20. ErrNotExist = errors.New("Record does not exist")
  21. ErrNotInTransaction = errors.New("Not in transaction.")
  22. ErrNestedTransaction = errors.New("Nested transaction error.")
  23. ErrTransactionDefinition = errors.New("Transaction definition error.")
  24. // ErrCacheFailed cache failed error
  25. ErrCacheFailed = errors.New("Cache failed")
  26. // ErrNeedDeletedCond delete needs less one condition error
  27. ErrNeedDeletedCond = errors.New("Delete action needs at least one condition")
  28. // ErrNotImplemented not implemented
  29. ErrNotImplemented = errors.New("Not implemented")
  30. // ErrConditionType condition type unsupported
  31. ErrConditionType = errors.New("Unsupported condition type")
  32. // ErrNeedMoreArguments need more arguments
  33. ErrNeedMoreArguments = errors.New("Need more sql arguments")
  34. // ErrUnSupportedSQLType parameter of SQL is not supported
  35. ErrUnSupportedSQLType = errors.New("Unsupported sql type")
  36. )
  37. // ErrFieldIsNotExist columns does not exist
  38. type ErrFieldIsNotExist struct {
  39. FieldName string
  40. TableName string
  41. }
  42. func (e ErrFieldIsNotExist) Error() string {
  43. return fmt.Sprintf("field %s is not valid on table %s", e.FieldName, e.TableName)
  44. }
  45. // ErrFieldIsNotValid is not valid
  46. type ErrFieldIsNotValid struct {
  47. FieldName string
  48. TableName string
  49. }
  50. func (e ErrFieldIsNotValid) Error() string {
  51. return fmt.Sprintf("field %s is not valid on table %s", e.FieldName, e.TableName)
  52. }