Sha256: f366db108943cb91cf8270d164a59d4a51e99c9324dc8e4daa4a1763e4ed5384
Contents?: true
Size: 702 Bytes
Versions: 27
Compression:
Stored size: 702 Bytes
Contents
module BTC # Several functions intended to detect bad data in runtime and throw exceptions. # These are for programmer's errors, not for bad user input. # Bad user input should never raise exceptions. module Safety def AssertType(value, type) if !value.is_a?(type) raise ArgumentError, "Value #{value.inspect} must be of type #{type}!" end end def AssertTypeOrNil(value, type) return if value == nil AssertType(value, type) end # Checks invariant and raises an exception. def Invariant(condition, message) if !condition raise RuntimeError, "BTC Invariant Failure: #{message}" end end end include Safety end
Version data entries
27 entries across 27 versions & 1 rubygems