PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/error.js

https://github.com/leancloud/javascript-sdk
JavaScript | 345 lines | 61 code | 51 blank | 233 comment | 1 complexity | 086c0a4d82b0cf053f37faeb87d1d38b MD5 | raw file
  1. (function(root) {
  2. root.AV = root.AV || {};
  3. var AV = root.AV;
  4. var _ = AV._;
  5. /**
  6. * Constructs a new AV.Error object with the given code and message.
  7. * @param {Number} code An error code constant from <code>AV.Error</code>.
  8. * @param {String} message A detailed description of the error.
  9. * @class
  10. *
  11. * <p>Class used for all objects passed to error callbacks.</p>
  12. */
  13. AV.Error = function(code, message) {
  14. this.code = code;
  15. this.message = message;
  16. };
  17. _.extend(AV.Error, /** @lends AV.Error */ {
  18. /**
  19. * Error code indicating some error other than those enumerated here.
  20. * @constant
  21. */
  22. OTHER_CAUSE: -1,
  23. /**
  24. * Error code indicating that something has gone wrong with the server.
  25. * If you get this error code, it is AV's fault. Contact us at
  26. * https://avoscloud.com/help
  27. * @constant
  28. */
  29. INTERNAL_SERVER_ERROR: 1,
  30. /**
  31. * Error code indicating the connection to the AV servers failed.
  32. * @constant
  33. */
  34. CONNECTION_FAILED: 100,
  35. /**
  36. * Error code indicating the specified object doesn't exist.
  37. * @constant
  38. */
  39. OBJECT_NOT_FOUND: 101,
  40. /**
  41. * Error code indicating you tried to query with a datatype that doesn't
  42. * support it, like exact matching an array or object.
  43. * @constant
  44. */
  45. INVALID_QUERY: 102,
  46. /**
  47. * Error code indicating a missing or invalid classname. Classnames are
  48. * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
  49. * only valid characters.
  50. * @constant
  51. */
  52. INVALID_CLASS_NAME: 103,
  53. /**
  54. * Error code indicating an unspecified object id.
  55. * @constant
  56. */
  57. MISSING_OBJECT_ID: 104,
  58. /**
  59. * Error code indicating an invalid key name. Keys are case-sensitive. They
  60. * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
  61. * @constant
  62. */
  63. INVALID_KEY_NAME: 105,
  64. /**
  65. * Error code indicating a malformed pointer. You should not see this unless
  66. * you have been mucking about changing internal AV code.
  67. * @constant
  68. */
  69. INVALID_POINTER: 106,
  70. /**
  71. * Error code indicating that badly formed JSON was received upstream. This
  72. * either indicates you have done something unusual with modifying how
  73. * things encode to JSON, or the network is failing badly.
  74. * @constant
  75. */
  76. INVALID_JSON: 107,
  77. /**
  78. * Error code indicating that the feature you tried to access is only
  79. * available internally for testing purposes.
  80. * @constant
  81. */
  82. COMMAND_UNAVAILABLE: 108,
  83. /**
  84. * You must call AV.initialize before using the AV library.
  85. * @constant
  86. */
  87. NOT_INITIALIZED: 109,
  88. /**
  89. * Error code indicating that a field was set to an inconsistent type.
  90. * @constant
  91. */
  92. INCORRECT_TYPE: 111,
  93. /**
  94. * Error code indicating an invalid channel name. A channel name is either
  95. * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
  96. * characters and starts with a letter.
  97. * @constant
  98. */
  99. INVALID_CHANNEL_NAME: 112,
  100. /**
  101. * Error code indicating that push is misconfigured.
  102. * @constant
  103. */
  104. PUSH_MISCONFIGURED: 115,
  105. /**
  106. * Error code indicating that the object is too large.
  107. * @constant
  108. */
  109. OBJECT_TOO_LARGE: 116,
  110. /**
  111. * Error code indicating that the operation isn't allowed for clients.
  112. * @constant
  113. */
  114. OPERATION_FORBIDDEN: 119,
  115. /**
  116. * Error code indicating the result was not found in the cache.
  117. * @constant
  118. */
  119. CACHE_MISS: 120,
  120. /**
  121. * Error code indicating that an invalid key was used in a nested
  122. * JSONObject.
  123. * @constant
  124. */
  125. INVALID_NESTED_KEY: 121,
  126. /**
  127. * Error code indicating that an invalid filename was used for AVFile.
  128. * A valid file name contains only a-zA-Z0-9_. characters and is between 1
  129. * and 128 characters.
  130. * @constant
  131. */
  132. INVALID_FILE_NAME: 122,
  133. /**
  134. * Error code indicating an invalid ACL was provided.
  135. * @constant
  136. */
  137. INVALID_ACL: 123,
  138. /**
  139. * Error code indicating that the request timed out on the server. Typically
  140. * this indicates that the request is too expensive to run.
  141. * @constant
  142. */
  143. TIMEOUT: 124,
  144. /**
  145. * Error code indicating that the email address was invalid.
  146. * @constant
  147. */
  148. INVALID_EMAIL_ADDRESS: 125,
  149. /**
  150. * Error code indicating a missing content type.
  151. * @constant
  152. */
  153. MISSING_CONTENT_TYPE: 126,
  154. /**
  155. * Error code indicating a missing content length.
  156. * @constant
  157. */
  158. MISSING_CONTENT_LENGTH: 127,
  159. /**
  160. * Error code indicating an invalid content length.
  161. * @constant
  162. */
  163. INVALID_CONTENT_LENGTH: 128,
  164. /**
  165. * Error code indicating a file that was too large.
  166. * @constant
  167. */
  168. FILE_TOO_LARGE: 129,
  169. /**
  170. * Error code indicating an error saving a file.
  171. * @constant
  172. */
  173. FILE_SAVE_ERROR: 130,
  174. /**
  175. * Error code indicating an error deleting a file.
  176. * @constant
  177. */
  178. FILE_DELETE_ERROR: 153,
  179. /**
  180. * Error code indicating that a unique field was given a value that is
  181. * already taken.
  182. * @constant
  183. */
  184. DUPLICATE_VALUE: 137,
  185. /**
  186. * Error code indicating that a role's name is invalid.
  187. * @constant
  188. */
  189. INVALID_ROLE_NAME: 139,
  190. /**
  191. * Error code indicating that an application quota was exceeded. Upgrade to
  192. * resolve.
  193. * @constant
  194. */
  195. EXCEEDED_QUOTA: 140,
  196. /**
  197. * Error code indicating that a Cloud Code script failed.
  198. * @constant
  199. */
  200. SCRIPT_FAILED: 141,
  201. /**
  202. * Error code indicating that a Cloud Code validation failed.
  203. * @constant
  204. */
  205. VALIDATION_ERROR: 142,
  206. /**
  207. * Error code indicating that invalid image data was provided.
  208. * @constant
  209. */
  210. INVALID_IMAGE_DATA: 150,
  211. /**
  212. * Error code indicating an unsaved file.
  213. * @constant
  214. */
  215. UNSAVED_FILE_ERROR: 151,
  216. /**
  217. * Error code indicating an invalid push time.
  218. */
  219. INVALID_PUSH_TIME_ERROR: 152,
  220. /**
  221. * Error code indicating that the username is missing or empty.
  222. * @constant
  223. */
  224. USERNAME_MISSING: 200,
  225. /**
  226. * Error code indicating that the password is missing or empty.
  227. * @constant
  228. */
  229. PASSWORD_MISSING: 201,
  230. /**
  231. * Error code indicating that the username has already been taken.
  232. * @constant
  233. */
  234. USERNAME_TAKEN: 202,
  235. /**
  236. * Error code indicating that the email has already been taken.
  237. * @constant
  238. */
  239. EMAIL_TAKEN: 203,
  240. /**
  241. * Error code indicating that the email is missing, but must be specified.
  242. * @constant
  243. */
  244. EMAIL_MISSING: 204,
  245. /**
  246. * Error code indicating that a user with the specified email was not found.
  247. * @constant
  248. */
  249. EMAIL_NOT_FOUND: 205,
  250. /**
  251. * Error code indicating that a user object without a valid session could
  252. * not be altered.
  253. * @constant
  254. */
  255. SESSION_MISSING: 206,
  256. /**
  257. * Error code indicating that a user can only be created through signup.
  258. * @constant
  259. */
  260. MUST_CREATE_USER_THROUGH_SIGNUP: 207,
  261. /**
  262. * Error code indicating that an an account being linked is already linked
  263. * to another user.
  264. * @constant
  265. */
  266. ACCOUNT_ALREADY_LINKED: 208,
  267. /**
  268. * Error code indicating that a user cannot be linked to an account because
  269. * that account's id could not be found.
  270. * @constant
  271. */
  272. LINKED_ID_MISSING: 250,
  273. /**
  274. * Error code indicating that a user with a linked (e.g. Facebook) account
  275. * has an invalid session.
  276. * @constant
  277. */
  278. INVALID_LINKED_SESSION: 251,
  279. /**
  280. * Error code indicating that a service being linked (e.g. Facebook or
  281. * Twitter) is unsupported.
  282. * @constant
  283. */
  284. UNSUPPORTED_SERVICE: 252,
  285. /**
  286. * Error code indicating a real error code is unavailable because
  287. * we had to use an XDomainRequest object to allow CORS requests in
  288. * Internet Explorer, which strips the body from HTTP responses that have
  289. * a non-2XX status code.
  290. * @constant
  291. */
  292. X_DOMAIN_REQUEST: 602
  293. });
  294. }(this));