File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 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;
343343 */
344344ParseError . FILE_DELETE_ERROR = 153 ;
345345
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+
346354/**
347355 * Error code indicating that the application has exceeded its request
348356 * limit.
Original file line number Diff line number Diff line change 1212import CoreManager from './CoreManager' ;
1313import type { FullOptions } from './RESTController' ;
1414
15+ const ParseError = require ( './ParseError' ) . default ;
16+
1517let XHR = null ;
1618if ( typeof XMLHttpRequest !== 'undefined' ) {
1719 XHR = XMLHttpRequest ;
@@ -314,13 +316,13 @@ class ParseFile {
314316
315317 /**
316318 * 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.
318320 *
319321 * @returns {Promise } Promise that is resolved when the delete finishes.
320322 */
321323 destroy ( ) {
322324 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 .' ) ;
324326 }
325327 const controller = CoreManager . getFileController ( ) ;
326328 return controller . deleteFile ( this . _name ) . then ( ( ) => {
Original file line number Diff line number Diff line change @@ -820,7 +820,7 @@ describe('FileController', () => {
820820 try {
821821 await file . destroy ( ) ;
822822 } catch ( e ) {
823- expect ( e . message ) . toBe ( 'Cannot delete an unsaved ParseFile.' ) ;
823+ expect ( e . code ) . toBe ( ParseError . FILE_DELETE_UNNAMED_ERROR ) ;
824824 done ( ) ;
825825 }
826826 } ) ;
You can’t perform that action at this time.
0 commit comments