e.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. package common_err
  2. const (
  3. SUCCESS = 200
  4. SERVICE_ERROR = 500
  5. CLIENT_ERROR = 400
  6. ERROR_AUTH_TOKEN = 401
  7. INVALID_PARAMS = 4000
  8. //user
  9. PWD_INVALID = 10001
  10. PWD_IS_EMPTY = 10002
  11. PWD_INVALID_OLD = 10003
  12. ACCOUNT_LOCK = 10004
  13. PWD_IS_TOO_SIMPLE = 10005
  14. USER_NOT_EXIST = 10006
  15. USER_EXIST = 10007
  16. KEY_NOT_EXIST = 10008
  17. NOT_IMAGE = 10009
  18. IMAGE_TOO_LARGE = 10010
  19. INSUFFICIENT_PERMISSIONS = 10011
  20. //system
  21. DIR_ALREADY_EXISTS = 20001
  22. FILE_ALREADY_EXISTS = 20002
  23. FILE_OR_DIR_EXISTS = 20003
  24. PORT_IS_OCCUPIED = 20004
  25. COMMAND_ERROR_INVALID_OPERATION = 20005
  26. VERIFICATION_FAILURE = 20006
  27. Record_NOT_EXIST = 20007
  28. Record_ALREADY_EXIST = 20008
  29. SERVICE_NOT_RUNNING = 20009
  30. CHARACTER_LIMIT = 20010
  31. //disk
  32. NAME_NOT_AVAILABLE = 40001
  33. DISK_NEEDS_FORMAT = 40002
  34. DISK_BUSYING = 40003
  35. REMOVE_MOUNT_POINT_ERROR = 40004
  36. FORMAT_ERROR = 40005
  37. //app
  38. UNINSTALL_APP_ERROR = 50001
  39. PULL_IMAGE_ERROR = 50002
  40. DEVICE_NOT_EXIST = 50003
  41. ERROR_APP_NAME_EXIST = 50004
  42. //file
  43. FILE_DOES_NOT_EXIST = 60001
  44. FILE_READ_ERROR = 60002
  45. FILE_DELETE_ERROR = 60003
  46. DIR_NOT_EXISTS = 60004
  47. SOURCE_DES_SAME = 60005
  48. MOUNTED_DIRECTIORIES = 60006
  49. //share
  50. SHARE_ALREADY_EXISTS = 70001
  51. SHARE_NAME_ALREADY_EXISTS = 70002
  52. )
  53. var MsgFlags = map[int]string{
  54. SUCCESS: "ok",
  55. SERVICE_ERROR: "Fail",
  56. CLIENT_ERROR: "Fail",
  57. INVALID_PARAMS: "Parameters Error",
  58. ERROR_AUTH_TOKEN: "Error auth token",
  59. //user
  60. PWD_INVALID: "Invalid password",
  61. PWD_IS_EMPTY: "Password is empty",
  62. PWD_INVALID_OLD: "Invalid old password",
  63. ACCOUNT_LOCK: "Account is locked",
  64. PWD_IS_TOO_SIMPLE: "Password is too simple",
  65. USER_NOT_EXIST: "User does not exist",
  66. USER_EXIST: "User already exists",
  67. KEY_NOT_EXIST: "Key does not exist",
  68. IMAGE_TOO_LARGE: "Image is too large",
  69. NOT_IMAGE: "Not an image",
  70. INSUFFICIENT_PERMISSIONS: "Insufficient permissions",
  71. //system
  72. DIR_ALREADY_EXISTS: "Folder already exists",
  73. FILE_ALREADY_EXISTS: "File already exists",
  74. FILE_OR_DIR_EXISTS: "File or folder already exists",
  75. PORT_IS_OCCUPIED: "Port is occupied",
  76. VERIFICATION_FAILURE: "Verification failure",
  77. Record_ALREADY_EXIST: "Record already exists",
  78. Record_NOT_EXIST: "Record does not exist",
  79. SERVICE_NOT_RUNNING: "Service is not running",
  80. CHARACTER_LIMIT: "Only uppercase letters, lowercase letters and numbers are allowed for username and password.",
  81. //app
  82. UNINSTALL_APP_ERROR: "Error uninstalling app",
  83. PULL_IMAGE_ERROR: "Error pulling image",
  84. DEVICE_NOT_EXIST: "Device does not exist",
  85. ERROR_APP_NAME_EXIST: "App name already exists",
  86. //disk
  87. NAME_NOT_AVAILABLE: "Name not available",
  88. DISK_NEEDS_FORMAT: "Drive needs to be formatted",
  89. REMOVE_MOUNT_POINT_ERROR: "Failed to remove mount point",
  90. DISK_BUSYING: "Drive is busy",
  91. FORMAT_ERROR: "Formatting failed, please check if the directory is occupied",
  92. //share
  93. SHARE_ALREADY_EXISTS: "Share already exists",
  94. SHARE_NAME_ALREADY_EXISTS: "Share name already exists",
  95. //
  96. SOURCE_DES_SAME: "Source and destination cannot be the same.",
  97. FILE_DOES_NOT_EXIST: "File does not exist",
  98. DIR_NOT_EXISTS: "Directory does not exist",
  99. FILE_READ_ERROR: "File read error",
  100. FILE_DELETE_ERROR: "Delete error",
  101. MOUNTED_DIRECTIORIES: "The directory is mounted, please unmount it first.",
  102. COMMAND_ERROR_INVALID_OPERATION: "invalid operation",
  103. }
  104. // 获取错误信息
  105. func GetMsg(code int) string {
  106. msg, ok := MsgFlags[code]
  107. if ok {
  108. return msg
  109. }
  110. return MsgFlags[SERVICE_ERROR]
  111. }