From d0b96ad4fb1ed5b71a87b41ad49806c17478ffdb Mon Sep 17 00:00:00 2001 From: John Fairhurst Date: Mon, 10 Feb 2025 11:22:32 +0000 Subject: [PATCH] Stop crashes during exception handling --- Sources/RubyGateway/RbError.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/RubyGateway/RbError.swift b/Sources/RubyGateway/RbError.swift index 230e90c..63bcfa3 100644 --- a/Sources/RubyGateway/RbError.swift +++ b/Sources/RubyGateway/RbError.swift @@ -214,7 +214,7 @@ public struct RbException: CustomStringConvertible, Error { /// The exception's message public var description: String { - let exceptionClass = try! exception.get("class") + let exceptionClass = (try? exception.get("class")) ?? "(Unknown Ruby exception type)" return "\(exceptionClass): \(exception)" } }