Mailinglist Archive: yast-commit (1771 mails)

< Previous Next >
[yast-commit] <rest-service> basesystem : return proper status if the setting does not exist
  • From: Duncan Mac-Vicar P <dmacvicar@xxxxxxx>
  • Date: Mon, 31 Aug 2009 00:50:08 +0200
  • Message-id: <E1Mj7Ka-0002qD-My@xxxxxxxxxxxxxxxx>
ref: refs/heads/basesystem
commit 71dcc3daa541ba426774103247fb42cb393808d8
Author: Duncan Mac-Vicar P <dmacvicar@xxxxxxx>
Date: Mon Aug 31 00:50:08 2009 +0200

return proper status if the setting does not exist
---
.../app/controllers/vendor_settings_controller.rb | 24 +++++++++++++++++--
1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/webservice/app/controllers/vendor_settings_controller.rb
b/webservice/app/controllers/vendor_settings_controller.rb
index 20d9420..9b51d73 100644
--- a/webservice/app/controllers/vendor_settings_controller.rb
+++ b/webservice/app/controllers/vendor_settings_controller.rb
@@ -3,7 +3,14 @@ require 'vendor_setting'
class VendorSettingsController < ApplicationController

def index
- settings = VendorSetting.find(:all)
+ settings = []
+ begin
+ settings = VendorSetting.find(:all)
+ rescue YaST::ConfigFile::NotFoundError
+ render :nothing => true, :status => 404 and return
+ rescue Exception => e
+ render :nothing => true, :status => 500 and return
+ end
respond_to do |format|
format.xml { render :xml => settings.to_xml }
format.json { render :json => VendorSetting }
@@ -11,9 +18,20 @@ class VendorSettingsController < ApplicationController
end

def show
- setting = VendorSetting.find(params[:id])
+ setting = nil
+ begin
+ setting = VendorSetting.find(params[:id])
+ if setting.nil?
+ render :nothing => true, :status => 404 and return
+ end
+ rescue YaST::ConfigFile::NotFoundError
+ render :nothing => true, :status => 404 and return
+ rescue Exception => e
+ render :nothing => true, :status => 500 and return
+ end
+
respond_to do |format|
- format.xml { render :xml => settings.to_xml }
+ format.xml { render :xml => setting.to_xml }
format.json { render :json => setting.value.to_json }
end
end
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages