You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2013/02/22 11:32:25 UTC

[1/12] git commit: CIMI: Capture the validation errors and advertise them as HTTP 400

CIMI: Capture the validation errors and advertise them as HTTP 400

In case when client sent scrumbed XML or JSON body, this patch
will make sure we send 'HTTP 400 - Bad Request' back instead of
horrible looking 500 error.

This patch also properly advertise the ValidationError in case
when client want to create CIMI resource but the validation conditions
are not met.


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/44957a97
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/44957a97
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/44957a97

Branch: refs/heads/master
Commit: 44957a97f8ae699d68ed947f61be8fd645639194
Parents: bcd5c45
Author: Michal Fojtik <mf...@redhat.com>
Authored: Thu Feb 7 13:35:35 2013 +0100
Committer: Michal fojtik <mf...@redhat.com>
Committed: Thu Feb 21 15:31:31 2013 +0100

----------------------------------------------------------------------
 server/lib/cimi/collections/base.rb |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/44957a97/server/lib/cimi/collections/base.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/collections/base.rb b/server/lib/cimi/collections/base.rb
index 75a8bae..6c38f9b 100644
--- a/server/lib/cimi/collections/base.rb
+++ b/server/lib/cimi/collections/base.rb
@@ -53,6 +53,18 @@ module CIMI::Collections
       report_error
     end
 
+    error CIMI::Model::ValidationError do
+      report_error
+    end
+
+    error JSON::ParserError do
+      report_error(400)
+    end
+
+    error REXML::ParseException do
+      report_error(400)
+    end
+
     before do
       # Respond with 400, If we don't get a http Host header,
       halt 400, "Unable to find HTTP Host header" if @env['HTTP_HOST'] == nil