Fix crash in render_error(not_an_exception), and use raise() rather
authorTom Clegg <tom@curoverse.com>
Thu, 13 Mar 2014 04:17:06 +0000 (00:17 -0400)
committerTom Clegg <tom@curoverse.com>
Thu, 13 Mar 2014 04:17:06 +0000 (00:17 -0400)
than calling render_error() directly from ApplicationController#save
and #update

services/api/app/controllers/application_controller.rb

index 4061b7de5b429a3025d6227d461507c9cd8463d0..7c10c8425ddc51114ce81f791702c504bd48d524 100644 (file)
@@ -38,7 +38,7 @@ class ApplicationController < ActionController::Base
     if @object.save
       show
     else
-      render_error "Save failed"
+      raise "Save failed"
     end
   end
 
@@ -49,7 +49,7 @@ class ApplicationController < ActionController::Base
     if @object.update_attributes attrs_to_update
       show
     else
-      render_error "Update failed"
+      raise "Update failed"
     end
   end
 
@@ -87,7 +87,9 @@ class ApplicationController < ActionController::Base
 
   def render_error(e)
     logger.error e.inspect
-    logger.error e.backtrace.collect { |x| x + "\n" }.join('') if e.backtrace
+    if e.respond_to? :backtrace and e.backtrace
+      logger.error e.backtrace.collect { |x| x + "\n" }.join('')
+    end
     if @object and @object.errors and @object.errors.full_messages and not @object.errors.full_messages.empty?
       errors = @object.errors.full_messages
     else