enhanced exception handling in some view files

This commit is contained in:
hyung-hwan 2016-12-19 13:39:40 +00:00
parent b4288906e4
commit 4d2025c5f4
4 changed files with 29 additions and 12 deletions

View File

@ -237,7 +237,10 @@ var revision_network = null;
function show_revision_graph (response)
{
var data = $.parseJSON(response);
var data;
try { data = $.parseJSON(response); }
catch (e) { data = null; }
if (data == null)
{
show_alert ('Invalid data received', "<?php print $this->lang->line('Error')?>");
@ -252,7 +255,7 @@ function show_revision_graph (response)
autoResize: false,
height: '500px',
width: '100%',
clickToUse: true,
clickToUse: false,
layout: {
hierarchical: {
enabled: true,

View File

@ -107,7 +107,10 @@ function show_tooltip(id, x, y, contents) {
function show_loc_by_lang_graph (response)
{
var loc = $.parseJSON(response);
var loc;
try { loc = $.parseJSON(response); }
catch (e) { loc = null; }
if (loc == null)
{
show_alert ('Invalid data received', "<?php print $this->lang->line('Error')?>");
@ -186,7 +189,10 @@ function show_loc_by_lang_graph (response)
function show_loc_by_file_graph (response)
{
var loc = $.parseJSON(response);
var loc;
try { loc = $.parseJSON(response); }
catch (e) { loc = null; }
if (loc == null)
{
show_alert ('Invalid data received', "<?php print $this->lang->line('Error')?>");
@ -205,7 +211,10 @@ var revision_network = null;
function show_revision_graph (response)
{
var data = $.parseJSON(response);
var data;
try { data = $.parseJSON(response); }
catch (e) { data = null; }
if (data == null)
{
show_alert ('Invalid data received', "<?php print $this->lang->line('Error')?>");
@ -220,7 +229,7 @@ function show_revision_graph (response)
autoResize: false,
height: '500px',
width: '100%',
clickToUse: true,
clickToUse: false,
layout: {
hierarchical: {
enabled: true,

View File

@ -395,15 +395,18 @@ function show_commits_per_user_graph(log)
function show_all_graphs (response)
{
var log = $.parseJSON(response);
if (log == null)
var data;
try { data = $.parseJSON(response); }
catch (e) { data = null; }
if (data == null)
{
alert ('Invalid data received');
}
else if (log.length > 0)
else if (data.length > 0)
{
show_commits_per_month_graph (log);
show_commits_per_user_graph (log);
show_commits_per_month_graph (data);
show_commits_per_user_graph (data);
}
else
{

View File

@ -144,7 +144,9 @@ var GraphApp = (function()
function show_graph (response)
{
var data = $.parseJSON(response);
var data;
try { data = $.parseJSON(response); } // TODO: for jquery 3.0 or later, JSON.parse() should be used.
catch (e) { data = null; }
if (data == null)
{