git » swiftpm » commit 5a504b4

Include whole erorr message in exception

author Stephen Paul Weber
2026-10-27 21:19:11 UTC
committer Stephen Paul Weber
2026-10-27 21:29:30 UTC
parent 6f33bf125a48959b3364dfaf6e605f56482428c8

Include whole erorr message in exception

Sources/c_borogove/src/hx/libs/ssl/SSL.cpp +20 -1

diff --git a/Sources/c_borogove/src/hx/libs/ssl/SSL.cpp b/Sources/c_borogove/src/hx/libs/ssl/SSL.cpp
index a76bd19..a3ab79d 100644
--- a/Sources/c_borogove/src/hx/libs/ssl/SSL.cpp
+++ b/Sources/c_borogove/src/hx/libs/ssl/SSL.cpp
@@ -150,7 +150,26 @@ void _hx_ssl_handshake(Dynamic hssl) {
 	sslctx* ctx = val_ssl(hssl);
 	OSStatus s = SSLHandshake(ctx->sslCtx);
 	if (s == errSSLWouldBlock) return _hx_ssl_handshake(hssl);
-	if (s != noErr) hx::Throw(HX_CSTRING("SSL handshake error"));
+
+	if (s != noErr) {
+		CFStringRef message = SecCopyErrorMessageString(s, NULL);
+		char description[256] = "Unknown error";
+
+		if (message) {
+			CFStringGetCString(
+				message,
+				description,
+				sizeof(description),
+				kCFStringEncodingUTF8
+			);
+			CFRelease(message);
+		}
+
+		hx::Throw(
+			String("SSL handshake error ") +
+			String((int)s) + String(": ") + String(description)
+		);
+	}
 }
 
 int _hx_ssl_send(Dynamic hssl, Array<unsigned char> buf, int p, int l) {