RbError

Swift
public enum RbError: Error

extension RbError: CustomStringConvertible

An error raised by the RubyGateway module. Ruby exceptions generate RbError.rubyException(_:), unusual Ruby flow control generates RbError.rubyJump(_:), and the other cases correspond to error conditions encountered by the Swift software.


Topics

Cases

case setup(String)

The Ruby VM could not be set up.

Declaration
Swift
case setup(String)

case badType(String)

An object has the wrong type for an operation.

Raised for example when setting a CVar on a non-class object.

Declaration
Swift
case badType(String)

case badParameter(String)

A value passed to the library is out of range for some reason.

Raised for example when declaring a method with fixed arity > 15.

Declaration
Swift
case badParameter(String)

case badIdentifier(type: String, id: String)

An identifier looks to be spelt wrong.

Raised for example when an IVar name does not begin with ‘@’.

Declaration
Swift
case badIdentifier(type: String, id: String)

case duplicateKwArg(String)

A keyword argument is duplicated.

Raised when a kwArgs parameter is passed and the list contains duplicate argument keywords.

Declaration
Swift
case duplicateKwArg(String)

case rubyException(RbException)

A Ruby exception occurred.

You are free to ignore or handle this error. If your code has been invoked from Ruby then you can also re-throw the error to pass it back down the stack.

Declaration
Swift
case rubyException(RbException)

case rubyJump(Int32)

Some Ruby flow control has happened.

Raised when you invoke a block from Swift and the block does return or break. You must do any Swift-side cleanup and re-throw the error without talking to Ruby, otherwise the Ruby runtime will become confused at best.

Declaration
Swift
case rubyJump(Int32)

Error History

class History

Holds the most recent errors thrown by RubyGateway.

This can be useful when the module indicates an error has occurred through a nil result somewhere – the error causing the nil has still been generated internally and is stashed here.

These nil results happen during type conversion to Swift, for example String.init(_:), and when using the RbObjectAccess.failable adapter that suppresses throwing.

Methods are thread-safe.

Declaration
Swift
public final class History: Sendable

static var history: RbError.History

A short history of errors thrown by RubyGateway

Declaration
Swift
public static let history: RbError.History

CustomStringConvertible

var description: String

A human-readable description of the error.

Declaration
Swift
public var description: String { get }