From e54705a9adfabb0dc49174b85feccc45b30c5d9d Mon Sep 17 00:00:00 2001 From: Jon M Date: Wed, 12 Jun 2024 08:06:54 +0100 Subject: [PATCH] Show criteria upon search timeout --- lib/Mailosaur/messages.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Mailosaur/messages.rb b/lib/Mailosaur/messages.rb index 3a44855..b1e8879 100644 --- a/lib/Mailosaur/messages.rb +++ b/lib/Mailosaur/messages.rb @@ -172,7 +172,9 @@ def search(server, criteria, page: nil, items_per_page: nil, timeout: nil, recei if ((1000 * (Time.now.to_f - start_time).to_i) + delay) > timeout return Mailosaur::Models::MessageListResult.new(model) unless error_on_timeout - raise Mailosaur::MailosaurError.new('No matching messages found in time. By default, only messages received in the last hour are checked (use receivedAfter to override this).', 'search_timeout') + msg = format('No matching messages found in time. By default, only messages received in the last hour are checked (use receivedAfter to override this). The search criteria used for this query was [%s] which timed out after %sms', + criteria.to_json, timeout) + raise Mailosaur::MailosaurError.new(msg, 'search_timeout') end sleep(delay / 1000)