myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2781] trunk/lib/rest.rb: changed REST response t


From: noreply
Subject: [myexperiment-hackers] [2781] trunk/lib/rest.rb: changed REST response to a 400 for invalid search queries
Date: Tue, 1 Nov 2011 11:09:52 -0400 (EDT)

Revision
2781
Author
dgc
Date
2011-11-01 11:09:52 -0400 (Tue, 01 Nov 2011)

Log Message

changed REST response to a 400 for invalid search queries

Modified Paths

Diff

Modified: trunk/lib/rest.rb (2780 => 2781)


--- trunk/lib/rest.rb	2011-11-01 15:02:35 UTC (rev 2780)
+++ trunk/lib/rest.rb	2011-11-01 15:09:52 UTC (rev 2781)
@@ -1393,12 +1393,8 @@
     q      = args[:query]
     models = args[:models]
 
-    begin
-      search_result = models[0].multi_solr_search(q, :limit => size, :offset => size * (page - 1), :models => models)
-      search_result.results unless search_result.total < (size * (page - 1))
-    rescue
-      nil
-    end
+    search_result = models[0].multi_solr_search(q, :limit => size, :offset => size * (page - 1), :models => models)
+    search_result.results unless search_result.total < (size * (page - 1))
   }
 end
 
@@ -1470,9 +1466,12 @@
   attributes['query'] = search_query
   attributes['type'] = opts[:query]['type'] if models.length == 1
 
-  obs = paginated_search_index(search_query, models, num, page, opts[:user])
-
-  produce_rest_list(opts[:req_uri], opts[:rules], opts[:query], obs, 'search', attributes, opts[:user])
+  begin
+    obs = paginated_search_index(search_query, models, num, page, opts[:user])
+    produce_rest_list(opts[:req_uri], opts[:rules], opts[:query], obs, 'search', attributes, opts[:user])
+  rescue
+    rest_response(400, :reason => "Invalid search query")
+  end
 end
 
 def user_count(opts)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]