ソースを参照

Exceptions: Change Core.log(3) to throw new Error

<verbose & clean code/>
@soyjavi 14 年 前
コミット
0bc9cb356c

+ 2 - 1
src/Lungo.Constants.js

@@ -65,8 +65,9 @@ LUNGO.Constants = {
         BINDING_TEMPLATE: 'ERROR: Binding Template not exists >> ',
         BINDING_LIST: 'ERROR: Processing parameters for list binding.',
         DATABASE: 'ERROR: Connecting to Data.Sql.',
+        DATABASE_TRANSACTION: 'ERROR: Data.Sql >> ',
         ROUTER: 'ERROR: The target does not exists >>',
-        LOADING_RESOURCE: 'ERROR: Loading resource.'
+        LOADING_RESOURCE: 'ERROR: Loading resource: '
     }
 
 };

+ 1 - 1
src/Lungo.Core.js

@@ -217,4 +217,4 @@ LUNGO.Core = (function(lng, $$, undefined) {
         findByProperty: findByProperty
     };
 
-})(LUNGO, Quo);
+})(LUNGO, Quo);

+ 3 - 3
src/boot/Lungo.Boot.Resources.js

@@ -41,7 +41,7 @@ LUNGO.Boot.Resources = (function(lng, $$, undefined) {
                 var response = _loadAsyncResource(url);
                 _factoryResources(resource_key, response);
             } catch(error) {
-                lng.Core.log(3, ERROR.LOADING_RESOURCE + ' ' + error);
+                lng.Core.log(3, error.message);
             }
         }
     };
@@ -62,7 +62,7 @@ LUNGO.Boot.Resources = (function(lng, $$, undefined) {
             async: false,
             dataType: 'html',
             error: function() {
-                console.error('[ERROR] Loading url', arguments);
+                throw new Error(ERROR.LOADING_RESOURCE + url);
             }
         });
     };
@@ -103,4 +103,4 @@ LUNGO.Boot.Resources = (function(lng, $$, undefined) {
         start: start
     };
 
-})(LUNGO, Quo);
+})(LUNGO, Quo);

+ 3 - 3
src/data/Lungo.Data.Sql.js

@@ -34,7 +34,7 @@ LUNGO.Data.Sql = (function(lng, undefined) {
         if (db) {
             _createSchema();
         } else {
-            lng.Core.log(3, ERROR.DATABASE);
+            throw new Error(ERROR.DATABASE);
         }
     };
 
@@ -202,7 +202,7 @@ LUNGO.Data.Sql = (function(lng, undefined) {
     };
 
     var _throwError = function(transaction, error) {
-        lng.Core.log(3, 'lng.Data.Sql >> ' + error.code + ': ' + error.message + ' \n Executed query: ' + transaction.executedQuery);
+        throw new Error(ERROR.DATABASE_TRANSACTION + error.code + ': ' + error.message + ' \n Executed query: ' + transaction.executedQuery);
     };
 
     return {
@@ -214,4 +214,4 @@ LUNGO.Data.Sql = (function(lng, undefined) {
         execute: execute
     };
 
-})(LUNGO);
+})(LUNGO);

+ 2 - 2
src/view/Lungo.View.Template.Binding.js

@@ -29,7 +29,7 @@ LUNGO.View.Template.Binding = (function(lng, undefined) {
         } else if (data_type === 'object') {
             return _bindProperties(data, markup);
         } else {
-            lng.Core.log(3, ERROR.BINDING_DATA_TYPE);
+            throw new Error(ERROR.BINDING_DATA_TYPE);
         }
     };
 
@@ -70,4 +70,4 @@ LUNGO.View.Template.Binding = (function(lng, undefined) {
         dataAttribute: dataAttribute
     };
 
-})(LUNGO);
+})(LUNGO);

+ 2 - 2
src/view/Lungo.View.Template.List.js

@@ -71,7 +71,7 @@ LUNGO.View.Template.List = (function(lng, undefined) {
                 checked = true;
             }
         } else {
-            lng.Core.log(3, ERROR.BINDING_LIST);
+            throw new Error(ERROR.BINDING_LIST);
         }
 
         return checked;
@@ -98,4 +98,4 @@ LUNGO.View.Template.List = (function(lng, undefined) {
         prepend: prepend
     };
 
-})(LUNGO);
+})(LUNGO);

+ 2 - 2
src/view/Lungo.View.Template.js

@@ -64,7 +64,7 @@ LUNGO.View.Template = (function(lng, undefined) {
             var container = lng.dom(element);
             container.html(this.markup(template_id, data));
         } else {
-            lng.Core.log(3, ERROR.BINDING_TEMPLATE + template_id);
+            throw new Error(ERROR.BINDING_TEMPLATE + template_id);
         }
     };
 
@@ -102,4 +102,4 @@ LUNGO.View.Template = (function(lng, undefined) {
         html: html
     };
 
-})(LUNGO);
+})(LUNGO);