e.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. //share
  49. SHARE_ALREADY_EXISTS = 70001
  50. SHARE_NAME_ALREADY_EXISTS = 70002
  51. )
  52. var MsgFlags = map[int]string{
  53. SUCCESS: "ok",
  54. SERVICE_ERROR: "Fail",
  55. CLIENT_ERROR: "Fail",
  56. INVALID_PARAMS: "Parameters Error",
  57. ERROR_AUTH_TOKEN: "Error auth token",
  58. //user
  59. PWD_INVALID: "Invalid password",
  60. PWD_IS_EMPTY: "Password is empty",
  61. PWD_INVALID_OLD: "Invalid old password",
  62. ACCOUNT_LOCK: "Account is locked",
  63. PWD_IS_TOO_SIMPLE: "Password is too simple",
  64. USER_NOT_EXIST: "User does not exist",
  65. USER_EXIST: "User already exists",
  66. KEY_NOT_EXIST: "Key does not exist",
  67. IMAGE_TOO_LARGE: "Image is too large",
  68. NOT_IMAGE: "Not an image",
  69. INSUFFICIENT_PERMISSIONS: "Insufficient permissions",
  70. //system
  71. DIR_ALREADY_EXISTS: "Folder already exists",
  72. FILE_ALREADY_EXISTS: "File already exists",
  73. FILE_OR_DIR_EXISTS: "File or folder already exists",
  74. PORT_IS_OCCUPIED: "Port is occupied",
  75. VERIFICATION_FAILURE: "Verification failure",
  76. Record_ALREADY_EXIST: "Record already exists",
  77. Record_NOT_EXIST: "Record does not exist",
  78. SERVICE_NOT_RUNNING: "Service is not running",
  79. CHARACTER_LIMIT: "Only uppercase letters, lowercase letters and numbers are allowed for username and password.",
  80. //app
  81. UNINSTALL_APP_ERROR: "Error uninstalling app",
  82. PULL_IMAGE_ERROR: "Error pulling image",
  83. DEVICE_NOT_EXIST: "Device does not exist",
  84. ERROR_APP_NAME_EXIST: "App name already exists",
  85. //disk
  86. NAME_NOT_AVAILABLE: "Name not available",
  87. DISK_NEEDS_FORMAT: "Drive needs to be formatted",
  88. REMOVE_MOUNT_POINT_ERROR: "Failed to remove mount point",
  89. DISK_BUSYING: "Drive is busy",
  90. FORMAT_ERROR: "Formatting failed, please check if the directory is occupied",
  91. //share
  92. SHARE_ALREADY_EXISTS: "Share already exists",
  93. SHARE_NAME_ALREADY_EXISTS: "Share name already exists",
  94. //
  95. SOURCE_DES_SAME: "Source and destination cannot be the same.",
  96. FILE_DOES_NOT_EXIST: "File does not exist",
  97. DIR_NOT_EXISTS: "Directory does not exist",
  98. FILE_READ_ERROR: "File read error",
  99. FILE_DELETE_ERROR: "Delete error",
  100. COMMAND_ERROR_INVALID_OPERATION: "invalid operation",
  101. }
  102. // 获取错误信息
  103. func GetMsg(code int) string {
  104. msg, ok := MsgFlags[code]
  105. if ok {
  106. return msg
  107. }
  108. return MsgFlags[SERVICE_ERROR]
  109. }