Permalink
Browse files

Improve error handling

  • Loading branch information...
1 parent a02b1d4 commit 28fb204458055e690cbc000089b65b94b871be8c @vmoravec vmoravec committed Mar 7, 2014
Showing with 12 additions and 8 deletions.
  1. +6 −4 library/systemd/src/modules/systemd_service.rb
  2. +6 −4 library/systemd/src/modules/systemd_socket.rb
@@ -65,7 +65,11 @@ module Yast
#
##
- class SystemdServiceNotFound < StandardError ; end
+ class SystemdServiceNotFound < StandardError
+ def initialize service_name
+ super "Service unit '#{service_name}' not found"
+ end
+ end
class SystemdServiceClass < Module
UNIT_SUFFIX = ".service"
@@ -78,9 +82,7 @@ def find service_name, properties={}
end
def find! service_name, properties={}
- service = find(service_name, properties)
- return service if service
- raise SystemdServiceNotFound, "Service unit '#{service_name}' not found"
+ find(service_name, properties) || raise(SystemdServiceNotFound, service_name)
end
def all properties={}
@@ -59,7 +59,11 @@ module Yast
#
##
- class SystemdSocketNotFound < StandardError ; end
+ class SystemdSocketNotFound < StandardError
+ def initialize socket_name
+ super "Socket unit '#{socket_name}' not found"
+ end
+ end
class SystemdSocketClass < Module
UNIT_SUFFIX = ".socket"
@@ -72,9 +76,7 @@ def find socket_name, properties={}
end
def find! socket_name, properties={}
- socket = find(socket_name, properties)
- return socket if socket
- raise SystemdSocketNotFound, "Socket unit '#{socket_name}' not found"
+ find(socket_name, properties) || raise(SystemdSocketNotFound, socket_name)
end
def all properties={}

0 comments on commit 28fb204

Please sign in to comment.