Improved error handling of 404 or 401 tickets.

This commit is contained in:
Martin Edenhofer 2015-01-13 22:55:20 +01:00
parent c5622e5432
commit 0e299ccf5b
2 changed files with 31 additions and 18 deletions

View file

@ -46,7 +46,8 @@ class App.TicketZoom extends App.Controller
meta = meta =
url: @url() url: @url()
id: @ticket_id id: @ticket_id
iconClass: "priority" iconClass: 'priority'
head: @taskTitle
if @ticket if @ticket
@ticket = App.Ticket.fullLocal( @ticket.id ) @ticket = App.Ticket.fullLocal( @ticket.id )
meta.head = @ticket.title meta.head = @ticket.title
@ -66,6 +67,7 @@ class App.TicketZoom extends App.Controller
@positionPageHeaderStop() @positionPageHeaderStop()
changed: => changed: =>
return false if !@ticket
formCurrent = @formParam( @el.find('.edit') ) formCurrent = @formParam( @el.find('.edit') )
ticket = App.Ticket.find(@ticket_id).attributes() ticket = App.Ticket.find(@ticket_id).attributes()
modelDiff = @getDiff( ticket, formCurrent ) modelDiff = @getDiff( ticket, formCurrent )
@ -114,11 +116,23 @@ class App.TicketZoom extends App.Controller
# do not close window if request is aborted # do not close window if request is aborted
return if status is 'abort' return if status is 'abort'
# do not close window on network error but if object is not found # show error message
return if status is 'error' && error isnt 'Not Found' if xhr.status is 401 || error is 'Unauthorized'
@taskTitle = '» ' + App.i18n.translateInline('Unauthorized') + ' «'
# remove task @html App.view('generic/error/unauthorized')()
App.TaskManager.remove( @task_key ) 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
)
) )

View file

@ -62,16 +62,15 @@ class _ajaxSingleton
# do not show aborded requests # do not show aborded requests
return if status is 0 return if status is 0
# do not show any error message on wrong login # 200, all is fine
return if status is 401 && !settings.url.match('login')
# do not show any error message with code 200
return if status is 200 return if status is 200
# show human readable message # do not show any error message with code 401/404 (handled by controllers)
if status is 401 return if status is 401
status = 'Access denied.' return if status is 404
detail = ''
# do not show any error message with code 502
return if status is 502
# show error message # show error message
new App.ErrorModal( new App.ErrorModal(