File tree 3 files changed +13
-3
lines changed
3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -343,6 +343,14 @@ ParseError.INVALID_PUSH_TIME_ERROR = 152;
343
343
*/
344
344
ParseError . FILE_DELETE_ERROR = 153 ;
345
345
346
+ /**
347
+ * Error code indicating an error deleting an unnamed file.
348
+ *
349
+ * @property {number } FILE_DELETE_UNNAMED_ERROR
350
+ * @static
351
+ */
352
+ ParseError . FILE_DELETE_UNNAMED_ERROR = 161 ;
353
+
346
354
/**
347
355
* Error code indicating that the application has exceeded its request
348
356
* limit.
Original file line number Diff line number Diff line change 12
12
import CoreManager from './CoreManager' ;
13
13
import type { FullOptions } from './RESTController' ;
14
14
15
+ const ParseError = require ( './ParseError' ) . default ;
16
+
15
17
let XHR = null ;
16
18
if ( typeof XMLHttpRequest !== 'undefined' ) {
17
19
XHR = XMLHttpRequest ;
@@ -314,13 +316,13 @@ class ParseFile {
314
316
315
317
/**
316
318
* Deletes the file from the Parse cloud.
317
- * In Cloud Code and Node only with Master Key
319
+ * In Cloud Code and Node only with Master Key.
318
320
*
319
321
* @returns {Promise } Promise that is resolved when the delete finishes.
320
322
*/
321
323
destroy ( ) {
322
324
if ( ! this . _name ) {
323
- throw new Error ( 'Cannot delete an unsaved ParseFile .' ) ;
325
+ throw new ParseError ( ParseError . FILE_DELETE_UNNAMED_ERROR , 'Cannot delete an unnamed file .' ) ;
324
326
}
325
327
const controller = CoreManager . getFileController ( ) ;
326
328
return controller . deleteFile ( this . _name ) . then ( ( ) => {
Original file line number Diff line number Diff line change @@ -820,7 +820,7 @@ describe('FileController', () => {
820
820
try {
821
821
await file . destroy ( ) ;
822
822
} catch ( e ) {
823
- expect ( e . message ) . toBe ( 'Cannot delete an unsaved ParseFile.' ) ;
823
+ expect ( e . code ) . toBe ( ParseError . FILE_DELETE_UNNAMED_ERROR ) ;
824
824
done ( ) ;
825
825
}
826
826
} ) ;
You can’t perform that action at this time.
0 commit comments