error.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. // ErrNeedMoreArguments need more arguments
  31. ErrNeedMoreArguments = errors.New("Need more sql arguments")
  32. // ErrUnSupportedSQLType parameter of SQL is not supported
  33. ErrUnSupportedSQLType = errors.New("unsupported sql type")
  34. )
  35. // ErrFieldIsNotExist columns does not exist
  36. type ErrFieldIsNotExist struct {
  37. FieldName string
  38. TableName string
  39. }
  40. func (e ErrFieldIsNotExist) Error() string {
  41. return fmt.Sprintf("field %s is not valid on table %s", e.FieldName, e.TableName)
  42. }
  43. // ErrFieldIsNotValid is not valid
  44. type ErrFieldIsNotValid struct {
  45. FieldName string
  46. TableName string
  47. }
  48. func (e ErrFieldIsNotValid) Error() string {
  49. return fmt.Sprintf("field %s is not valid on table %s", e.FieldName, e.TableName)
  50. }