From 5186e3cdb18053f2ebc1af1323386a9ad1eec898 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 8 Sep 2015 05:16:25 +0000 Subject: [PATCH] enhanced $.ajax error message handling --- codepot/src/codepot/views/code_folder.php | 21 ++++++++++++++++++--- codepot/src/codepot/views/file_home.php | 6 +++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/codepot/src/codepot/views/code_folder.php b/codepot/src/codepot/views/code_folder.php index b5523f6d..844e0855 100644 --- a/codepot/src/codepot/views/code_folder.php +++ b/codepot/src/codepot/views/code_folder.php @@ -318,7 +318,12 @@ $(function () { import_in_progress = false; $('#code_folder_mainarea_new_form_div').dialog('enable'); $('#code_folder_mainarea_new_form_div').dialog('close'); - show_alert ('Failed - ' + errorThrown, "lang->line('Error')?>"); + + var errmsg = ''; + if (errmsg == '' && errorThrown != null) errmsg = errorThrown; + if (errmsg == '' && textStatus != null) errmsg = textStatus; + if (errmsg == '') errmsg = 'Unknown error'; + show_alert ('Failed - ' + errmsg, "lang->line('Error')?>"); } }); } @@ -402,7 +407,12 @@ $(function () { delete_in_progress = false; $('#code_folder_mainarea_delete_form_div').dialog('enable'); $('#code_folder_mainarea_delete_form_div').dialog('close'); - show_alert ('Failed - ' + errorThrown, "lang->line('Error')?>"); + + var errmsg = ''; + if (errmsg == '' && errorThrown != null) errmsg = errorThrown; + if (errmsg == '' && textStatus != null) errmsg = textStatus; + if (errmsg == '') errmsg = 'Unknown error'; + show_alert ('Failed - ' + errmsg, "lang->line('Error')?>"); } }); } @@ -491,7 +501,12 @@ $(function () { rename_in_progress = false; $('#code_folder_mainarea_rename_form_div').dialog('enable'); $('#code_folder_mainarea_rename_form_div').dialog('close'); - show_alert ('Failed - ' + errorThrown, "lang->line('Error')?>"); + + var errmsg = ''; + if (errmsg == '' && errorThrown != null) errmsg = errorThrown; + if (errmsg == '' && textStatus != null) errmsg = textStatus; + if (errmsg == '') errmsg = 'Unknown error'; + show_alert ('Failed - ' + errmsg, "lang->line('Error')?>"); } }); } diff --git a/codepot/src/codepot/views/file_home.php b/codepot/src/codepot/views/file_home.php index cb999db2..1c4c5c78 100644 --- a/codepot/src/codepot/views/file_home.php +++ b/codepot/src/codepot/views/file_home.php @@ -189,7 +189,11 @@ $(function () { import_in_progress = false; $('#file_home_mainarea_new_form_div').dialog('enable'); $('#file_home_mainarea_new_form_div').dialog('close'); - show_alert ('Failed - ' + errorThrown, "lang->line('Error')?>"); + var errmsg = ''; + if (errmsg == '' && errorThrown != null) errmsg = errorThrown; + if (errmsg == '' && textStatus != null) errmsg = textStatus; + if (errmsg == '') errmsg = 'Unknown error'; + show_alert ('Failed - ' + errmsg, "lang->line('Error')?>"); } }); }