lib/simctl/command/list.rb in simctl-1.4.1 vs lib/simctl/command/list.rb in simctl-1.5.0
- old
+ new
@@ -1,6 +1,8 @@
module SimCtl
+ class DeviceTypeNotFound < StandardError; end
+ class RuntimeNotFound < StandardError; end
class Command
module List
COMMAND = %w[xcrun simctl list -j]
# Find a device
@@ -12,13 +14,14 @@
end
# Find a device type
#
# @param filter [Hash] the filter
- # @return [SimCtl::DeviceType, nil] the device type matching the given filter
+ # @return [SimCtl::DeviceType] the device type matching the given filter
+ # @raise [DeviceTypeNotFound] if the device type could not be found
def devicetype(filter)
- list_devicetypes.where(filter).first
+ list_devicetypes.where(filter).first or raise DeviceTypeNotFound.new("Could not find a device type matching #{filter.inspect}")
end
# List all devices
#
# @return [SimCtl::List] a list of SimCtl::Device objects
@@ -47,12 +50,13 @@
end
# Find a runtime
#
# @param filter [Hash] the filter
- # @return [SimCtl::Runtime, nil] the runtime matching the given filter
+ # @return [SimCtl::Runtime] the runtime matching the given filter
+ # @raise [RuntimeNotFound] if the runtime could not be found
def runtime(filter)
- list_runtimes.where(filter).first
+ list_runtimes.where(filter).first or raise RuntimeNotFound.new("Could not find a runtime matching #{filter.inspect}")
end
end
end
end