diff --git a/app/controllers/queued_posts_controller.rb b/app/controllers/queued_posts_controller.rb index d13de970817..6b225b5e65c 100644 --- a/app/controllers/queued_posts_controller.rb +++ b/app/controllers/queued_posts_controller.rb @@ -25,13 +25,17 @@ class QueuedPostsController < ApplicationController end state = params[:queued_post][:state] - if state == 'approved' - qp.approve!(current_user) - elsif state == 'rejected' - qp.reject!(current_user) - if params[:queued_post][:delete_user] == 'true' && guardian.can_delete_user?(qp.user) - UserDestroyer.new(current_user).destroy(qp.user, user_deletion_opts) + begin + if state == 'approved' + qp.approve!(current_user) + elsif state == 'rejected' + qp.reject!(current_user) + if params[:queued_post][:delete_user] == 'true' && guardian.can_delete_user?(qp.user) + UserDestroyer.new(current_user).destroy(qp.user, user_deletion_opts) + end end + rescue StandardError => e + return render_json_error e.message end render_serialized(qp, QueuedPostSerializer, root: :queued_posts) diff --git a/app/models/queued_post.rb b/app/models/queued_post.rb index 9dd479a73c2..351187a2ec4 100644 --- a/app/models/queued_post.rb +++ b/app/models/queued_post.rb @@ -70,7 +70,7 @@ class QueuedPost < ActiveRecord::Base created_post = creator.create unless created_post && creator.errors.blank? - raise StandardError, "Failed to create post #{raw[0..100]} #{creator.errors.full_messages.inspect}" + raise StandardError.new(creator.errors.full_messages.join(" ")) end end