Pool: raise custom error when DB::PoolTimeout

This commit is contained in:
syeopite 2025-04-09 18:34:11 -07:00
parent f32c954859
commit fbccb6a221
No known key found for this signature in database
GPG Key ID: A73C186DA3955A1A

View File

@ -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