ParseError.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. /**
  2. * Copyright (c) 2015-present, Parse, LLC.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. /**
  10. * Constructs a new Parse.Error object with the given code and message.
  11. * @alias Parse.Error
  12. */
  13. class ParseError extends Error {
  14. /**
  15. * @param {Number} code An error code constant from <code>Parse.Error</code>.
  16. * @param {String} message A detailed description of the error.
  17. */
  18. constructor(code, message) {
  19. super(message);
  20. this.code = code;
  21. Object.defineProperty(this, 'message', {
  22. enumerable: true,
  23. value: message
  24. });
  25. }
  26. toString() {
  27. return 'ParseError: ' + this.code + ' ' + this.message;
  28. }
  29. }
  30. /**
  31. * Error code indicating some error other than those enumerated here.
  32. * @property OTHER_CAUSE
  33. * @static
  34. * @final
  35. */
  36. ParseError.OTHER_CAUSE = -1;
  37. /**
  38. * Error code indicating that something has gone wrong with the server.
  39. * If you get this error code, it is Parse's fault. Contact us at
  40. * https://parse.com/help
  41. * @property INTERNAL_SERVER_ERROR
  42. * @static
  43. * @final
  44. */
  45. ParseError.INTERNAL_SERVER_ERROR = 1;
  46. /**
  47. * Error code indicating the connection to the Parse servers failed.
  48. * @property CONNECTION_FAILED
  49. * @static
  50. * @final
  51. */
  52. ParseError.CONNECTION_FAILED = 100;
  53. /**
  54. * Error code indicating the specified object doesn't exist.
  55. * @property OBJECT_NOT_FOUND
  56. * @static
  57. * @final
  58. */
  59. ParseError.OBJECT_NOT_FOUND = 101;
  60. /**
  61. * Error code indicating you tried to query with a datatype that doesn't
  62. * support it, like exact matching an array or object.
  63. * @property INVALID_QUERY
  64. * @static
  65. * @final
  66. */
  67. ParseError.INVALID_QUERY = 102;
  68. /**
  69. * Error code indicating a missing or invalid classname. Classnames are
  70. * case-sensitive. They must start with a letter, and a-zA-Z0-9_ are the
  71. * only valid characters.
  72. * @property INVALID_CLASS_NAME
  73. * @static
  74. * @final
  75. */
  76. ParseError.INVALID_CLASS_NAME = 103;
  77. /**
  78. * Error code indicating an unspecified object id.
  79. * @property MISSING_OBJECT_ID
  80. * @static
  81. * @final
  82. */
  83. ParseError.MISSING_OBJECT_ID = 104;
  84. /**
  85. * Error code indicating an invalid key name. Keys are case-sensitive. They
  86. * must start with a letter, and a-zA-Z0-9_ are the only valid characters.
  87. * @property INVALID_KEY_NAME
  88. * @static
  89. * @final
  90. */
  91. ParseError.INVALID_KEY_NAME = 105;
  92. /**
  93. * Error code indicating a malformed pointer. You should not see this unless
  94. * you have been mucking about changing internal Parse code.
  95. * @property INVALID_POINTER
  96. * @static
  97. * @final
  98. */
  99. ParseError.INVALID_POINTER = 106;
  100. /**
  101. * Error code indicating that badly formed JSON was received upstream. This
  102. * either indicates you have done something unusual with modifying how
  103. * things encode to JSON, or the network is failing badly.
  104. * @property INVALID_JSON
  105. * @static
  106. * @final
  107. */
  108. ParseError.INVALID_JSON = 107;
  109. /**
  110. * Error code indicating that the feature you tried to access is only
  111. * available internally for testing purposes.
  112. * @property COMMAND_UNAVAILABLE
  113. * @static
  114. * @final
  115. */
  116. ParseError.COMMAND_UNAVAILABLE = 108;
  117. /**
  118. * You must call Parse.initialize before using the Parse library.
  119. * @property NOT_INITIALIZED
  120. * @static
  121. * @final
  122. */
  123. ParseError.NOT_INITIALIZED = 109;
  124. /**
  125. * Error code indicating that a field was set to an inconsistent type.
  126. * @property INCORRECT_TYPE
  127. * @static
  128. * @final
  129. */
  130. ParseError.INCORRECT_TYPE = 111;
  131. /**
  132. * Error code indicating an invalid channel name. A channel name is either
  133. * an empty string (the broadcast channel) or contains only a-zA-Z0-9_
  134. * characters and starts with a letter.
  135. * @property INVALID_CHANNEL_NAME
  136. * @static
  137. * @final
  138. */
  139. ParseError.INVALID_CHANNEL_NAME = 112;
  140. /**
  141. * Error code indicating that push is misconfigured.
  142. * @property PUSH_MISCONFIGURED
  143. * @static
  144. * @final
  145. */
  146. ParseError.PUSH_MISCONFIGURED = 115;
  147. /**
  148. * Error code indicating that the object is too large.
  149. * @property OBJECT_TOO_LARGE
  150. * @static
  151. * @final
  152. */
  153. ParseError.OBJECT_TOO_LARGE = 116;
  154. /**
  155. * Error code indicating that the operation isn't allowed for clients.
  156. * @property OPERATION_FORBIDDEN
  157. * @static
  158. * @final
  159. */
  160. ParseError.OPERATION_FORBIDDEN = 119;
  161. /**
  162. * Error code indicating the result was not found in the cache.
  163. * @property CACHE_MISS
  164. * @static
  165. * @final
  166. */
  167. ParseError.CACHE_MISS = 120;
  168. /**
  169. * Error code indicating that an invalid key was used in a nested
  170. * JSONObject.
  171. * @property INVALID_NESTED_KEY
  172. * @static
  173. * @final
  174. */
  175. ParseError.INVALID_NESTED_KEY = 121;
  176. /**
  177. * Error code indicating that an invalid filename was used for ParseFile.
  178. * A valid file name contains only a-zA-Z0-9_. characters and is between 1
  179. * and 128 characters.
  180. * @property INVALID_FILE_NAME
  181. * @static
  182. * @final
  183. */
  184. ParseError.INVALID_FILE_NAME = 122;
  185. /**
  186. * Error code indicating an invalid ACL was provided.
  187. * @property INVALID_ACL
  188. * @static
  189. * @final
  190. */
  191. ParseError.INVALID_ACL = 123;
  192. /**
  193. * Error code indicating that the request timed out on the server. Typically
  194. * this indicates that the request is too expensive to run.
  195. * @property TIMEOUT
  196. * @static
  197. * @final
  198. */
  199. ParseError.TIMEOUT = 124;
  200. /**
  201. * Error code indicating that the email address was invalid.
  202. * @property INVALID_EMAIL_ADDRESS
  203. * @static
  204. * @final
  205. */
  206. ParseError.INVALID_EMAIL_ADDRESS = 125;
  207. /**
  208. * Error code indicating a missing content type.
  209. * @property MISSING_CONTENT_TYPE
  210. * @static
  211. * @final
  212. */
  213. ParseError.MISSING_CONTENT_TYPE = 126;
  214. /**
  215. * Error code indicating a missing content length.
  216. * @property MISSING_CONTENT_LENGTH
  217. * @static
  218. * @final
  219. */
  220. ParseError.MISSING_CONTENT_LENGTH = 127;
  221. /**
  222. * Error code indicating an invalid content length.
  223. * @property INVALID_CONTENT_LENGTH
  224. * @static
  225. * @final
  226. */
  227. ParseError.INVALID_CONTENT_LENGTH = 128;
  228. /**
  229. * Error code indicating a file that was too large.
  230. * @property FILE_TOO_LARGE
  231. * @static
  232. * @final
  233. */
  234. ParseError.FILE_TOO_LARGE = 129;
  235. /**
  236. * Error code indicating an error saving a file.
  237. * @property FILE_SAVE_ERROR
  238. * @static
  239. * @final
  240. */
  241. ParseError.FILE_SAVE_ERROR = 130;
  242. /**
  243. * Error code indicating that a unique field was given a value that is
  244. * already taken.
  245. * @property DUPLICATE_VALUE
  246. * @static
  247. * @final
  248. */
  249. ParseError.DUPLICATE_VALUE = 137;
  250. /**
  251. * Error code indicating that a role's name is invalid.
  252. * @property INVALID_ROLE_NAME
  253. * @static
  254. * @final
  255. */
  256. ParseError.INVALID_ROLE_NAME = 139;
  257. /**
  258. * Error code indicating that an application quota was exceeded. Upgrade to
  259. * resolve.
  260. * @property EXCEEDED_QUOTA
  261. * @static
  262. * @final
  263. */
  264. ParseError.EXCEEDED_QUOTA = 140;
  265. /**
  266. * Error code indicating that a Cloud Code script failed.
  267. * @property SCRIPT_FAILED
  268. * @static
  269. * @final
  270. */
  271. ParseError.SCRIPT_FAILED = 141;
  272. /**
  273. * Error code indicating that a Cloud Code validation failed.
  274. * @property VALIDATION_ERROR
  275. * @static
  276. * @final
  277. */
  278. ParseError.VALIDATION_ERROR = 142;
  279. /**
  280. * Error code indicating that invalid image data was provided.
  281. * @property INVALID_IMAGE_DATA
  282. * @static
  283. * @final
  284. */
  285. ParseError.INVALID_IMAGE_DATA = 143;
  286. /**
  287. * Error code indicating an unsaved file.
  288. * @property UNSAVED_FILE_ERROR
  289. * @static
  290. * @final
  291. */
  292. ParseError.UNSAVED_FILE_ERROR = 151;
  293. /**
  294. * Error code indicating an invalid push time.
  295. * @property INVALID_PUSH_TIME_ERROR
  296. * @static
  297. * @final
  298. */
  299. ParseError.INVALID_PUSH_TIME_ERROR = 152;
  300. /**
  301. * Error code indicating an error deleting a file.
  302. * @property FILE_DELETE_ERROR
  303. * @static
  304. * @final
  305. */
  306. ParseError.FILE_DELETE_ERROR = 153;
  307. /**
  308. * Error code indicating that the application has exceeded its request
  309. * limit.
  310. * @property REQUEST_LIMIT_EXCEEDED
  311. * @static
  312. * @final
  313. */
  314. ParseError.REQUEST_LIMIT_EXCEEDED = 155;
  315. /**
  316. * Error code indicating an invalid event name.
  317. * @property INVALID_EVENT_NAME
  318. * @static
  319. * @final
  320. */
  321. ParseError.INVALID_EVENT_NAME = 160;
  322. /**
  323. * Error code indicating that the username is missing or empty.
  324. * @property USERNAME_MISSING
  325. * @static
  326. * @final
  327. */
  328. ParseError.USERNAME_MISSING = 200;
  329. /**
  330. * Error code indicating that the password is missing or empty.
  331. * @property PASSWORD_MISSING
  332. * @static
  333. * @final
  334. */
  335. ParseError.PASSWORD_MISSING = 201;
  336. /**
  337. * Error code indicating that the username has already been taken.
  338. * @property USERNAME_TAKEN
  339. * @static
  340. * @final
  341. */
  342. ParseError.USERNAME_TAKEN = 202;
  343. /**
  344. * Error code indicating that the email has already been taken.
  345. * @property EMAIL_TAKEN
  346. * @static
  347. * @final
  348. */
  349. ParseError.EMAIL_TAKEN = 203;
  350. /**
  351. * Error code indicating that the email is missing, but must be specified.
  352. * @property EMAIL_MISSING
  353. * @static
  354. * @final
  355. */
  356. ParseError.EMAIL_MISSING = 204;
  357. /**
  358. * Error code indicating that a user with the specified email was not found.
  359. * @property EMAIL_NOT_FOUND
  360. * @static
  361. * @final
  362. */
  363. ParseError.EMAIL_NOT_FOUND = 205;
  364. /**
  365. * Error code indicating that a user object without a valid session could
  366. * not be altered.
  367. * @property SESSION_MISSING
  368. * @static
  369. * @final
  370. */
  371. ParseError.SESSION_MISSING = 206;
  372. /**
  373. * Error code indicating that a user can only be created through signup.
  374. * @property MUST_CREATE_USER_THROUGH_SIGNUP
  375. * @static
  376. * @final
  377. */
  378. ParseError.MUST_CREATE_USER_THROUGH_SIGNUP = 207;
  379. /**
  380. * Error code indicating that an an account being linked is already linked
  381. * to another user.
  382. * @property ACCOUNT_ALREADY_LINKED
  383. * @static
  384. * @final
  385. */
  386. ParseError.ACCOUNT_ALREADY_LINKED = 208;
  387. /**
  388. * Error code indicating that the current session token is invalid.
  389. * @property INVALID_SESSION_TOKEN
  390. * @static
  391. * @final
  392. */
  393. ParseError.INVALID_SESSION_TOKEN = 209;
  394. /**
  395. * Error code indicating that a user cannot be linked to an account because
  396. * that account's id could not be found.
  397. * @property LINKED_ID_MISSING
  398. * @static
  399. * @final
  400. */
  401. ParseError.LINKED_ID_MISSING = 250;
  402. /**
  403. * Error code indicating that a user with a linked (e.g. Facebook) account
  404. * has an invalid session.
  405. * @property INVALID_LINKED_SESSION
  406. * @static
  407. * @final
  408. */
  409. ParseError.INVALID_LINKED_SESSION = 251;
  410. /**
  411. * Error code indicating that a service being linked (e.g. Facebook or
  412. * Twitter) is unsupported.
  413. * @property UNSUPPORTED_SERVICE
  414. * @static
  415. * @final
  416. */
  417. ParseError.UNSUPPORTED_SERVICE = 252;
  418. /**
  419. * Error code indicating an invalid operation occured on schema
  420. * @property INVALID_SCHEMA_OPERATION
  421. * @static
  422. * @final
  423. */
  424. ParseError.INVALID_SCHEMA_OPERATION = 255;
  425. /**
  426. * Error code indicating that there were multiple errors. Aggregate errors
  427. * have an "errors" property, which is an array of error objects with more
  428. * detail about each error that occurred.
  429. * @property AGGREGATE_ERROR
  430. * @static
  431. * @final
  432. */
  433. ParseError.AGGREGATE_ERROR = 600;
  434. /**
  435. * Error code indicating the client was unable to read an input file.
  436. * @property FILE_READ_ERROR
  437. * @static
  438. * @final
  439. */
  440. ParseError.FILE_READ_ERROR = 601;
  441. /**
  442. * Error code indicating a real error code is unavailable because
  443. * we had to use an XDomainRequest object to allow CORS requests in
  444. * Internet Explorer, which strips the body from HTTP responses that have
  445. * a non-2XX status code.
  446. * @property X_DOMAIN_REQUEST
  447. * @static
  448. * @final
  449. */
  450. ParseError.X_DOMAIN_REQUEST = 602;
  451. export default ParseError;