trilogy 2.13.2 → 2.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ea4b038d25e87b1d26c6dc0af6aa37b3cfa2b7244ea4788155bb392f7a5e93e
4
- data.tar.gz: c4201dd5f2c3974244cea9ae97af6052d3d1991509e64c2dde8319882b00a53e
3
+ metadata.gz: 18d367219cde913a99e5fcda45192907cce6577f5308d682b42b48f1d046bbb2
4
+ data.tar.gz: 2ddfd049d0061f446f18d378e0f297b757bf63f01015eb302541d6482ed388c4
5
5
  SHA512:
6
- metadata.gz: 2e58cdf8bf20b4d31e43b811ceb7972a772c2ccb44133f715a4d9c0723c1c1ed4b3139c5e7be68575b119932348f5d8d393d088b88fd73ba058eeef9d8203796
7
- data.tar.gz: ef9527a11371f0b6dbab901eb6c682e5a6e7cbf48d81e483b647682355b825a08ca342491a523859f543bfcaaf598588a713c5859baf8a883fe5adcda14f59ea
6
+ metadata.gz: ce0b26f62e79f480b89d902002b0cff30d85b2f7fcaddf1313c9d0127da87e200e719aeb9716641b343fe0fc6af2ee901f704d40e90f335352de147a63eb0920
7
+ data.tar.gz: 8c0b3ca40a1cc51ae4233086b2ed995a439a119114a01043877993a8a6268a4415d0e64338136f9c5f9ed42aa22b6dc497faf22a11ce894d50314500a3d2ced4
@@ -233,18 +233,22 @@ static struct trilogy_ctx *get_open_ctx(VALUE obj)
233
233
  return ctx;
234
234
  }
235
235
 
236
- NORETURN(static void trilogy_syserr_fail_str(int, VALUE));
237
- static void trilogy_syserr_fail_str(int e, VALUE msg)
236
+ static VALUE trilogy_new_syserr_fail(int e, VALUE msg)
238
237
  {
239
238
  if (e == EPIPE) {
240
239
  // Backwards compatibility: This error message is a bit odd, but includes "TRILOGY_CLOSED_CONNECTION" to match legacy string matching
241
- rb_raise(Trilogy_EOFError, "%" PRIsVALUE ": TRILOGY_CLOSED_CONNECTION: EPIPE", msg);
240
+ return rb_exc_new_str(Trilogy_EOFError, rb_sprintf("%" PRIsVALUE ": TRILOGY_CLOSED_CONNECTION: EPIPE", msg));
242
241
  } else {
243
- VALUE exc = rb_funcall(Trilogy_SyscallError, id_from_errno, 2, INT2NUM(e), msg);
244
- rb_exc_raise(exc);
242
+ return rb_funcall(Trilogy_SyscallError, id_from_errno, 2, INT2NUM(e), msg);
245
243
  }
246
244
  }
247
245
 
246
+ NORETURN(static void trilogy_syserr_fail_str(int, VALUE));
247
+ static void trilogy_syserr_fail_str(int e, VALUE msg)
248
+ {
249
+ rb_exc_raise(trilogy_new_syserr_fail(e, msg));
250
+ }
251
+
248
252
  static int trilogy_error_recoverable_p(int rc)
249
253
  {
250
254
  // TRILOGY_OPENSSL_ERR and TRILOGY_SYSERR (which can result from an SSL error) must shut down the socket, as further
@@ -263,8 +267,7 @@ static void handle_trilogy_error(struct trilogy_ctx *ctx, int rc, const char *ms
263
267
  va_start(args, msg);
264
268
  VALUE rbmsg = rb_vsprintf(msg, args);
265
269
  va_end(args);
266
-
267
- rb_trilogy_release_buffer(ctx);
270
+ VALUE exc;
268
271
 
269
272
  if (!trilogy_error_recoverable_p(rc)) {
270
273
  if (ctx->conn.socket != NULL) {
@@ -275,18 +278,23 @@ static void handle_trilogy_error(struct trilogy_ctx *ctx, int rc, const char *ms
275
278
  }
276
279
  }
277
280
 
281
+
278
282
  switch (rc) {
279
- case TRILOGY_SYSERR:
280
- trilogy_syserr_fail_str(errno, rbmsg);
283
+ case TRILOGY_SYSERR: {
284
+ exc = trilogy_new_syserr_fail(errno, rbmsg);
285
+ break;
286
+ }
281
287
 
282
- case TRILOGY_TIMEOUT:
283
- rb_raise(Trilogy_TimeoutError, "%" PRIsVALUE, rbmsg);
288
+ case TRILOGY_TIMEOUT: {
289
+ exc = rb_exc_new_str(Trilogy_TimeoutError, rbmsg);
290
+ break;
291
+ }
284
292
 
285
293
  case TRILOGY_ERR: {
286
294
  VALUE conn_message = rb_str_new(ctx->conn.error_message, ctx->conn.error_message_len);
287
295
  VALUE message = rb_sprintf("%" PRIsVALUE " (%" PRIsVALUE ")", conn_message, rbmsg);
288
- VALUE exc = rb_funcall(Trilogy_ProtocolError, id_from_code, 2, message, INT2NUM(ctx->conn.error_code));
289
- rb_exc_raise(exc);
296
+ exc = rb_funcall(Trilogy_ProtocolError, id_from_code, 2, message, INT2NUM(ctx->conn.error_code));
297
+ break;
290
298
  }
291
299
 
292
300
  case TRILOGY_OPENSSL_ERR: {
@@ -294,30 +302,48 @@ static void handle_trilogy_error(struct trilogy_ctx *ctx, int rc, const char *ms
294
302
  ERR_clear_error();
295
303
  if (ERR_GET_LIB(ossl_error) == ERR_LIB_SYS) {
296
304
  int err_reason = ERR_GET_REASON(ossl_error);
297
- trilogy_syserr_fail_str(err_reason, rbmsg);
305
+ exc = trilogy_new_syserr_fail(err_reason, rbmsg);
298
306
  }
299
- rb_raise(Trilogy_SSLError, "%" PRIsVALUE ": SSL Error: %s", rbmsg, ERR_reason_error_string(ossl_error));
307
+ else {
308
+ rbmsg = rb_sprintf("%" PRIsVALUE ": SSL Error: %s", rbmsg, ERR_reason_error_string(ossl_error));
309
+ exc = rb_exc_new_str(Trilogy_SSLError, rbmsg);
310
+ }
311
+ break;
300
312
  }
301
313
 
302
314
  case TRILOGY_DNS_ERR: {
303
- rb_raise(Trilogy_BaseConnectionError, "%" PRIsVALUE ": TRILOGY_DNS_ERROR", rbmsg);
315
+ rbmsg = rb_sprintf("%" PRIsVALUE ": TRILOGY_DNS_ERROR", rbmsg);
316
+ exc = rb_exc_new_str(Trilogy_BaseConnectionError, rbmsg);
317
+ break;
304
318
  }
305
319
 
306
320
  case TRILOGY_CLOSED_CONNECTION: {
307
- rb_raise(Trilogy_EOFError, "%" PRIsVALUE ": TRILOGY_CLOSED_CONNECTION", rbmsg);
321
+ rbmsg = rb_sprintf("%" PRIsVALUE ": TRILOGY_CLOSED_CONNECTION", rbmsg);
322
+ exc = rb_exc_new_str(Trilogy_EOFError, rbmsg);
323
+ break;
308
324
  }
309
325
 
310
326
  case TRILOGY_AUTH_PLUGIN_ERROR: {
311
- rb_raise(Trilogy_AuthPluginError, "%" PRIsVALUE ": TRILOGY_AUTH_PLUGIN_ERROR", rbmsg);
327
+ rbmsg = rb_sprintf("%" PRIsVALUE ": TRILOGY_AUTH_PLUGIN_ERROR", rbmsg);
328
+ exc = rb_exc_new_str(Trilogy_AuthPluginError, rbmsg);
329
+ break;
312
330
  }
313
331
 
314
332
  case TRILOGY_UNSUPPORTED: {
315
- rb_raise(Trilogy_BaseConnectionError, "%" PRIsVALUE ": TRILOGY_UNSUPPORTED", rbmsg);
333
+ rbmsg = rb_sprintf("%" PRIsVALUE ": TRILOGY_UNSUPPORTED", rbmsg);
334
+ exc = rb_exc_new_str(Trilogy_BaseConnectionError, rbmsg);
335
+ break;
316
336
  }
317
337
 
318
338
  default:
319
- rb_raise(Trilogy_QueryError, "%" PRIsVALUE ": %s", rbmsg, trilogy_error(rc));
339
+ rbmsg = rb_sprintf("%" PRIsVALUE ": %s", rbmsg, trilogy_error(rc));
340
+ exc = rb_exc_new_str(Trilogy_QueryError, rbmsg);
341
+ break;
320
342
  }
343
+
344
+ // Some error messages depend on the buffer.
345
+ rb_trilogy_release_buffer(ctx);
346
+ rb_exc_raise(exc);
321
347
  }
322
348
 
323
349
  static VALUE allocate_trilogy(VALUE klass)
@@ -1,3 +1,3 @@
1
1
  class Trilogy
2
- VERSION = "2.13.2"
2
+ VERSION = "2.13.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trilogy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.13.2
4
+ version: 2.13.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Engineering