mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-12-24 01:48:50 +00:00
Improved error functions
This commit is contained in:
parent
5b9b372ff9
commit
2352a47ab8
@ -4,12 +4,47 @@
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Submit an error
|
||||
*
|
||||
* @param {String} errorLevel The level of the error
|
||||
* @param {String} errorMessage The message associated with error
|
||||
* @param {Integer} errorCode The code of the error
|
||||
* @param {String} errorData Data associated with error
|
||||
*/
|
||||
ComunicWeb.common.error.submitError = function(errorLevel, errorMessage, errorCode, errorData){
|
||||
//Prepare API request
|
||||
var apiURI = "webApp/reportError";
|
||||
var params = {
|
||||
"errorLevel": errorLevel,
|
||||
"errorMessage": errorMessage,
|
||||
"errorCode": errorCode,
|
||||
"errorData": errorData.toSource(),
|
||||
}
|
||||
|
||||
//Not any next action for now
|
||||
nextAction = function(){};
|
||||
|
||||
//Send API request
|
||||
ComunicWeb.common.network.makeAPIrequest(apiURI, params, nextAction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle and show a fatal error
|
||||
*
|
||||
* @param {String} errorMessage Error message
|
||||
* @param {String} errorMessage The message associated with error
|
||||
* @param {Integer} errorCode The code of the error
|
||||
* @param {String} errorData Data associated with error
|
||||
*/
|
||||
ComunicWeb.common.error.fatalError = function(errorMessage){
|
||||
ComunicWeb.common.error.fatalError = function(errorMessage, errorCode, errorData){
|
||||
//Each not defined value is empty by default
|
||||
if(!errorMessage)
|
||||
var errorMessage = "Undefined error message";
|
||||
if(!errorCode)
|
||||
var errorCode = 0;
|
||||
if(!errorData)
|
||||
var errorData = {};
|
||||
|
||||
//Make a black splash screen
|
||||
var splashScreen = document.createElement("div");
|
||||
splashScreen.style.position = "fixed";
|
||||
@ -20,7 +55,7 @@ ComunicWeb.common.error.fatalError = function(errorMessage){
|
||||
splashScreen.style.backgroundColor = "#000000";
|
||||
|
||||
//Show a message on screen to inform user
|
||||
var messageElem = ComunicWeb.common.messages.createCalloutElem("Fatal error", "A fatal error occured : " + errorMessage + ". Please try to refresh the page...", "danger");
|
||||
var messageElem = ComunicWeb.common.messages.createCalloutElem(lang("__fatal_error"), lang("__fatal_error_explanation", [errorMessage]), "danger");
|
||||
messageElem.style.position = "relative";
|
||||
messageElem.style.margin = "auto";
|
||||
messageElem.style.width = "50%";
|
||||
@ -33,4 +68,5 @@ ComunicWeb.common.error.fatalError = function(errorMessage){
|
||||
document.body.appendChild(splashScreen);
|
||||
|
||||
//Make an API request to submit error
|
||||
this.submitError("fatal", errorMessage, errorCode, errorData);
|
||||
}
|
@ -65,13 +65,25 @@ var ComunicWeb = {
|
||||
* Error functions
|
||||
*/
|
||||
error:{
|
||||
/**
|
||||
* Submit an error
|
||||
*/
|
||||
submitError: function(errorLevel, errorMessage, errorCode, errorData){},
|
||||
|
||||
/**
|
||||
* Handle and show a fatal error
|
||||
*/
|
||||
fatalError: function(errorMessage){},
|
||||
fatalError: function(errorMessage, errorCode, errorData){},
|
||||
},
|
||||
|
||||
/**
|
||||
* URL functions
|
||||
*/
|
||||
url:{
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Operations on JS files
|
||||
*/
|
||||
|
5
assets/js/common/url.js
Normal file
5
assets/js/common/url.js
Normal file
@ -0,0 +1,5 @@
|
||||
/**
|
||||
* URL functions
|
||||
*
|
||||
* @author Pierre HUBERT
|
||||
*/
|
@ -4,8 +4,7 @@
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
ComunicWeb.common.langs.en = {
|
||||
//Basic messages
|
||||
"hello": "hello",
|
||||
|
||||
"__number_received_messages": "You have received %p messages",
|
||||
//Error messages
|
||||
"__fatal_error": "Fatal error",
|
||||
"__fatal_error_explanation": "A fatal error occured : <i>%p</i>. Please try to refresh the page...",
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
* @author Pierre HUBERT
|
||||
*/
|
||||
ComunicWeb.common.langs.fr = {
|
||||
//Basic messages
|
||||
"hello": "bonjour",
|
||||
"__number_received_messages": "Vous avez reçu %p messages",
|
||||
//Error messages
|
||||
"__fatal_error": "Erreur fatale",
|
||||
"__fatal_error_explanation": "Une erreur fatale a survenue : <i>%p</i>. Veuillez réessayer de recharger la page...",
|
||||
}
|
@ -26,6 +26,7 @@ $config['JSfiles'] = array(
|
||||
"%PATH_ASSETS%js/common/errors.js",
|
||||
"%PATH_ASSETS%js/common/messages.js",
|
||||
"%PATH_ASSETS%js/common/langs.js",
|
||||
"%PATH_ASSETS%js/common/url.js",
|
||||
"%PATH_ASSETS%js/common/jsFiles.js",
|
||||
"%PATH_ASSETS%js/common/debug.js",
|
||||
"%PATH_ASSETS%js/langs/en.inc.js",
|
||||
|
Loading…
Reference in New Issue
Block a user