From 97eacb472b8916ffbf42fb0147cb7632e389bae7 Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Thu, 19 Nov 2020 00:54:59 +0100 Subject: [PATCH 1/5] improved error message when deleting unnamed file --- src/ParseFile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ParseFile.js b/src/ParseFile.js index ec0a236c6..9a6932c64 100644 --- a/src/ParseFile.js +++ b/src/ParseFile.js @@ -320,7 +320,7 @@ class ParseFile { */ destroy() { if (!this._name) { - throw new Error('Cannot delete an unsaved ParseFile.'); + throw new Error('Cannot delete an unnamed file.'); } const controller = CoreManager.getFileController(); return controller.deleteFile(this._name).then(() => { From 6c9aa8a726efe1fc1cd9664d4954916d7c07144e Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Fri, 4 Dec 2020 13:01:48 +0100 Subject: [PATCH 2/5] Fixed typo --- src/ParseFile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ParseFile.js b/src/ParseFile.js index 9a6932c64..e6937d27d 100644 --- a/src/ParseFile.js +++ b/src/ParseFile.js @@ -314,7 +314,7 @@ class ParseFile { /** * Deletes the file from the Parse cloud. - * In Cloud Code and Node only with Master Key + * In Cloud Code and Node only with Master Key. * * @returns {Promise} Promise that is resolved when the delete finishes. */ From 1fbb8bed3ba5c35dd70c12ac47baf7176754eaee Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Sat, 5 Dec 2020 00:29:00 +0100 Subject: [PATCH 3/5] added new error for deleting unnamed file --- src/ParseError.js | 8 ++++++++ src/ParseFile.js | 2 +- src/__tests__/ParseFile-test.js | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ParseError.js b/src/ParseError.js index 4f8b11107..75721ad45 100644 --- a/src/ParseError.js +++ b/src/ParseError.js @@ -343,6 +343,14 @@ ParseError.INVALID_PUSH_TIME_ERROR = 152; */ ParseError.FILE_DELETE_ERROR = 153; +/** + * Error code indicating an error deleting an unnamed file. + * + * @property {number} FILE_DELETE_ERROR + * @static + */ +ParseError.FILE_DELETE_UNNAMED_ERROR = 154; + /** * Error code indicating that the application has exceeded its request * limit. diff --git a/src/ParseFile.js b/src/ParseFile.js index e6937d27d..3b526b025 100644 --- a/src/ParseFile.js +++ b/src/ParseFile.js @@ -320,7 +320,7 @@ class ParseFile { */ destroy() { if (!this._name) { - throw new Error('Cannot delete an unnamed file.'); + throw new ParseError(ParseError.FILE_DELETE_UNNAMED_ERROR, 'Cannot delete an unnamed file.'); } const controller = CoreManager.getFileController(); return controller.deleteFile(this._name).then(() => { diff --git a/src/__tests__/ParseFile-test.js b/src/__tests__/ParseFile-test.js index 2b03547bf..e1c41613a 100644 --- a/src/__tests__/ParseFile-test.js +++ b/src/__tests__/ParseFile-test.js @@ -820,7 +820,7 @@ describe('FileController', () => { try { await file.destroy(); } catch (e) { - expect(e.message).toBe('Cannot delete an unsaved ParseFile.'); + expect(e.code).toBe(ParseError.FILE_DELETE_UNNAMED_ERROR); done(); } }); From d75811f9591fe24c93f0de565ad9e01b2311b8df Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Sat, 5 Dec 2020 00:55:14 +0100 Subject: [PATCH 4/5] added Parse Error reference --- src/ParseFile.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ParseFile.js b/src/ParseFile.js index 3b526b025..2d377d302 100644 --- a/src/ParseFile.js +++ b/src/ParseFile.js @@ -12,6 +12,8 @@ import CoreManager from './CoreManager'; import type { FullOptions } from './RESTController'; +const ParseError = require('./ParseError').default; + let XHR = null; if (typeof XMLHttpRequest !== 'undefined') { XHR = XMLHttpRequest; From 8397e514f88f92600d954c9906b14120dfd8482b Mon Sep 17 00:00:00 2001 From: Manuel Trezza Date: Sat, 5 Dec 2020 01:16:35 +0100 Subject: [PATCH 5/5] changed error code had to change error code again because it was already used --- src/ParseError.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ParseError.js b/src/ParseError.js index 75721ad45..4053e9df9 100644 --- a/src/ParseError.js +++ b/src/ParseError.js @@ -346,10 +346,10 @@ ParseError.FILE_DELETE_ERROR = 153; /** * Error code indicating an error deleting an unnamed file. * - * @property {number} FILE_DELETE_ERROR + * @property {number} FILE_DELETE_UNNAMED_ERROR * @static */ -ParseError.FILE_DELETE_UNNAMED_ERROR = 154; +ParseError.FILE_DELETE_UNNAMED_ERROR = 161; /** * Error code indicating that the application has exceeded its request