From 970b4ce104aa6176dcf5635ca55b208d732f00fc Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sun, 26 Jun 2022 20:36:23 +0300 Subject: [PATCH] exceptions in module --- .../Espo/Resources/metadata/app/client.json | 4 +- client/src/app.js | 6 +- client/src/exceptions.js | 55 +++++++++++-------- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/application/Espo/Resources/metadata/app/client.json b/application/Espo/Resources/metadata/app/client.json index 4fed7dc647..3d4fac4a59 100644 --- a/application/Espo/Resources/metadata/app/client.json +++ b/application/Espo/Resources/metadata/app/client.json @@ -4,9 +4,7 @@ ], "developerModeScriptList": [ "client/src/loader.js", - "client/src/loader-init-libs.js", - "client/src/utils.js", - "client/src/exceptions.js" + "client/src/loader-init-libs.js" ], "linkList": [ { diff --git a/client/src/app.js b/client/src/app.js index 14fcd5b65b..c8d3cb26fb 100644 --- a/client/src/app.js +++ b/client/src/app.js @@ -59,7 +59,8 @@ define( 'ajax', 'number', 'page-title', - 'broadcast-channel' + 'broadcast-channel', + 'exceptions' ], function ( /** Espo */Espo, @@ -92,7 +93,8 @@ function ( Ajax, /** typeof module:number.Class */NumberUtil, /** typeof module:page-title.Class */PageTitle, - /** typeof module:broadcast-channel.Class */BroadcastChannel + /** typeof module:broadcast-channel.Class */BroadcastChannel, + Exceptions ) { /** * A main application class. diff --git a/client/src/exceptions.js b/client/src/exceptions.js index ff11fcfc0e..f7bbb7241a 100644 --- a/client/src/exceptions.js +++ b/client/src/exceptions.js @@ -26,34 +26,41 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.Exceptions = Espo.Exceptions || {}; - /** - * An access denied exception. - * - * @param {string} message A message. - * @class + * @module exceptions */ -Espo.Exceptions.AccessDenied = function (message) { - this.message = message; +define('exceptions', [], function () { + Espo.Exceptions = Espo.Exceptions || {}; - Error.apply(this, arguments); -}; + /** + * An access denied exception. + * + * @param {string} message A message. + * @class + */ + Espo.Exceptions.AccessDenied = function (message) { + this.message = message; -Espo.Exceptions.AccessDenied.prototype = new Error(); -Espo.Exceptions.AccessDenied.prototype.name = 'AccessDenied'; + Error.apply(this, arguments); + }; -/** - * A not found exception. - * - * @param {string} message A message. - * @class - */ -Espo.Exceptions.NotFound = function (message) { - this.message = message; + Espo.Exceptions.AccessDenied.prototype = new Error(); + Espo.Exceptions.AccessDenied.prototype.name = 'AccessDenied'; - Error.apply(this, arguments); -}; + /** + * A not found exception. + * + * @param {string} message A message. + * @class + */ + Espo.Exceptions.NotFound = function (message) { + this.message = message; -Espo.Exceptions.NotFound.prototype = new Error(); -Espo.Exceptions.NotFound.prototype.name = 'NotFound'; + Error.apply(this, arguments); + }; + + Espo.Exceptions.NotFound.prototype = new Error(); + Espo.Exceptions.NotFound.prototype.name = 'NotFound'; + + return Espo.Exceptions; +});