Skip to content

Commit 1fbb8be

Browse files
committed
added new error for deleting unnamed file
1 parent 6c9aa8a commit 1fbb8be

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/ParseError.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,14 @@ ParseError.INVALID_PUSH_TIME_ERROR = 152;
343343
*/
344344
ParseError.FILE_DELETE_ERROR = 153;
345345

346+
/**
347+
* Error code indicating an error deleting an unnamed file.
348+
*
349+
* @property {number} FILE_DELETE_ERROR
350+
* @static
351+
*/
352+
ParseError.FILE_DELETE_UNNAMED_ERROR = 154;
353+
346354
/**
347355
* Error code indicating that the application has exceeded its request
348356
* limit.

src/ParseFile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ class ParseFile {
320320
*/
321321
destroy() {
322322
if (!this._name) {
323-
throw new Error('Cannot delete an unnamed file.');
323+
throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.');
324324
}
325325
const controller = CoreManager.getFileController();
326326
return controller.deleteFile(this._name).then(() => {

src/__tests__/ParseFile-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)