From eba699b5ac09aa5e37272f16f8da93beda1394f7 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 7 Aug 2013 09:13:14 +0200 Subject: [PATCH] Improved error handling. --- .../javascripts/app/models/ticket.js.coffee | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/app/models/ticket.js.coffee b/app/assets/javascripts/app/models/ticket.js.coffee index f4283ac6b..0dcea0da6 100644 --- a/app/assets/javascripts/app/models/ticket.js.coffee +++ b/app/assets/javascripts/app/models/ticket.js.coffee @@ -33,17 +33,29 @@ class App.Ticket extends App.Model # customer if data.customer_id - data.customer = App.User.find( data.customer_id ) + if !App.User.exists( data.customer_id ) + console.error("Can't find user for data.customer_id #{data.customer_id} for ticket #{data.id}") + else + data.customer = App.User.find( data.customer_id ) # owner if data.owner_id - data.owner = App.User.find( data.owner_id ) + if !App.User.exists( data.owner_id ) + console.error("Can't find user for data.owner_id #{data.owner_id} for ticket #{data.id}") + else + data.owner = App.User.find( data.owner_id ) # add created & updated if data.created_by_id - data.created_by = App.User.find( data.created_by_id ) + if !App.User.exists( data.created_by_id ) + console.error("Can't find user for data.created_by_id #{data.created_by_id} for ticket #{data.id}") + else + data.created_by = App.User.find( data.created_by_id ) if data.updated_by_id - data.updated_by = App.User.find( data.updated_by_id ) + if !App.User.exists( data.updated_by_id ) + console.error("Can't find user for data.updated_by_id #{data.updated_by_id} for ticket #{data.id}") + else + data.updated_by = App.User.find( data.updated_by_id ) data