ref: refs/heads/network
commit 92fcff71646e5dc3b403682da65a02e37d977fc8
Author: Michal Zugec
Date: Thu Oct 1 16:19:18 2009 +0200
raise exception (and send it to the rest-api) if any error given
from YaPI
---
.../app/controllers/network/routes_controller.rb | 30 ++++++++++++++++---
plugins/network/app/models/route.rb | 2 +-
.../package/yast2-webservice-network.changes | 6 ++++
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/plugins/network/app/controllers/network/routes_controller.rb b/plugins/network/app/controllers/network/routes_controller.rb
index 4f7d1aa..64cd486 100644
--- a/plugins/network/app/controllers/network/routes_controller.rb
+++ b/plugins/network/app/controllers/network/routes_controller.rb
@@ -16,11 +16,12 @@ class Network::RoutesController < ApplicationController
@route = Route.find(root[:id])
@route.via = root[:via]
respond_to do |format|
- if @route.save
- format.xml { head :ok }
- else
- format.xml { render :xml => @route.errors, :status => :unprocessable_entity }
- end
+ ret = @route.save
+ if ret["exit"]=="0"
+ format.xml { head :ok }
+ else
+ raise RouteError.new ret["error"]
+ end
end
end
@@ -47,3 +48,22 @@ class Network::RoutesController < ApplicationController
end
end
+
+require 'exceptions'
+class RouteError < BackendException
+ def initialize(message)
+ @message = message
+ super("Failed to write route setting with this error: #{@message}.")
+ end
+
+ def to_xml
+ xml = Builder::XmlMarkup.new({})
+ xml.instruct!
+
+ xml.error do
+ xml.type "NETWORK_ROUTE_ERROR"
+ xml.description @message
+ xml.output @message
+ end
+ end
+end
diff --git a/plugins/network/app/models/route.rb b/plugins/network/app/models/route.rb
index 3934761..06bea10 100644
--- a/plugins/network/app/models/route.rb
+++ b/plugins/network/app/models/route.rb
@@ -42,7 +42,7 @@ class Route
@id => { 'via'=>@via },
}
vsettings = [ "a{sa{ss}}", settings ] # bnc#538050
- YastService.Call("YaPI::NETWORK::Write",{"route" => vsettings})
+ ret = YastService.Call("YaPI::NETWORK::Write",{"route" => vsettings})
# TODO success or not?
end
diff --git a/plugins/network/package/yast2-webservice-network.changes b/plugins/network/package/yast2-webservice-network.changes
index 12e7211..e35b73e 100644
--- a/plugins/network/package/yast2-webservice-network.changes
+++ b/plugins/network/package/yast2-webservice-network.changes
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Thu Oct 1 16:18:11 CEST 2009 - mzugec@suse.cz
+
+- raise exception (and send it to the rest-api) if any error given
+ from YaPI
+
+-------------------------------------------------------------------
Thu Oct 1 14:19:10 CEST 2009 - mvidner@suse.cz
- Fixed the YaPI dependency for SLE11.
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org