ParseError.js 13 KB

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