From 0e299ccf5b348b60a0fd7548ffd9b25ec5450d7c Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 13 Jan 2015 22:55:20 +0100 Subject: [PATCH] Improved error handling of 404 or 401 tickets. --- .../app/controllers/ticket_zoom.js.coffee | 34 +++++++++++++------ .../app/lib/app_post/ajax.js.coffee | 15 ++++---- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index c4e523d1c..69b7c70cb 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -44,14 +44,15 @@ class App.TicketZoom extends App.Controller meta: => meta = - url: @url() - id: @ticket_id - iconClass: "priority" + url: @url() + id: @ticket_id + iconClass: 'priority' + head: @taskTitle if @ticket - @ticket = App.Ticket.fullLocal( @ticket.id ) + @ticket = App.Ticket.fullLocal( @ticket.id ) meta.head = @ticket.title meta.title = '#' + @ticket.number + ' - ' + @ticket.title - meta.class = "level-#{@ticket.level()}" + meta.class = "level-#{@ticket.level()}" meta url: => @@ -66,6 +67,7 @@ class App.TicketZoom extends App.Controller @positionPageHeaderStop() changed: => + return false if !@ticket formCurrent = @formParam( @el.find('.edit') ) ticket = App.Ticket.find(@ticket_id).attributes() modelDiff = @getDiff( ticket, formCurrent ) @@ -114,11 +116,23 @@ class App.TicketZoom extends App.Controller # do not close window if request is aborted return if status is 'abort' - # do not close window on network error but if object is not found - return if status is 'error' && error isnt 'Not Found' - - # remove task - App.TaskManager.remove( @task_key ) + # show error message + if xhr.status is 401 || error is 'Unauthorized' + @taskTitle = '» ' + App.i18n.translateInline('Unauthorized') + ' «' + @html App.view('generic/error/unauthorized')() + else if xhr.status is 404 || error is 'Not Found' + @taskTitle = '» ' + App.i18n.translateInline('Not Found') + ' «' + @html App.view('generic/error/not_found')() + else + @taskTitle = '» ' + App.i18n.translateInline('Error') + ' «' + status = xhr.status + detail = xhr.responseText + if !status && !detail + detail = 'General communication error, maybe internet is not available!' + @html App.view('generic/error/generic')( + status: status + detail: detail + ) ) diff --git a/app/assets/javascripts/app/lib/app_post/ajax.js.coffee b/app/assets/javascripts/app/lib/app_post/ajax.js.coffee index 337139af8..095bda739 100644 --- a/app/assets/javascripts/app/lib/app_post/ajax.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/ajax.js.coffee @@ -62,16 +62,15 @@ class _ajaxSingleton # do not show aborded requests return if status is 0 - # do not show any error message on wrong login - return if status is 401 && !settings.url.match('login') - - # do not show any error message with code 200 + # 200, all is fine return if status is 200 - # show human readable message - if status is 401 - status = 'Access denied.' - detail = '' + # do not show any error message with code 401/404 (handled by controllers) + return if status is 401 + return if status is 404 + + # do not show any error message with code 502 + return if status is 502 # show error message new App.ErrorModal(