From fbccb6a2210b6eaad23900a27a21c828df31063d Mon Sep 17 00:00:00 2001 From: syeopite Date: Wed, 9 Apr 2025 18:34:11 -0700 Subject: [PATCH] Pool: raise custom error when `DB::PoolTimeout` --- src/invidious/connection/pool.cr | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/invidious/connection/pool.cr b/src/invidious/connection/pool.cr index f5d22f77..777188e5 100644 --- a/src/invidious/connection/pool.cr +++ b/src/invidious/connection/pool.cr @@ -72,7 +72,7 @@ module Invidious::ConnectionPool response = yield http_client rescue ex : DB::PoolTimeout # Failed to checkout a client - raise ConnectionPool::Error.new(ex.message, cause: ex) + raise ConnectionPool::PoolCheckoutError.new(ex.message) rescue ex # An error occurred with the client itself. # Delete the client from the pool and close the connection @@ -131,6 +131,10 @@ module Invidious::ConnectionPool class Error < Exception end + # Raised when the pool failed to get a client in time + class PoolCheckoutError < Error + end + # Mapping of subdomain => Invidious::ConnectionPool::Pool # This is needed as we may need to access arbitrary subdomains of ytimg private YTIMG_POOLS = {} of String => ConnectionPool::Pool