Skip to content

Commit

Permalink
Put rescue block outside the Timeout call
Browse files Browse the repository at this point in the history
Otherwise Timeout::Error won't be handled,
since it's raised by the Timeout::timeout
call itself.
  • Loading branch information
mildsunrise committed Feb 6, 2017
1 parent ec7bb95 commit 6a28e0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions telegram-history-dump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ def process_media(dialog, msg)
next unless $config['download_media'][media_type]
next unless msg['media']['type'] == media_type
response = nil
Timeout::timeout($config['media_timeout']) do
begin
begin
Timeout::timeout($config['media_timeout']) do
response = exec_tg_command('load_' + media_type, msg['id'])
rescue StandardError => e
$log.error('Failed to download media file: %s' % e)
end
rescue StandardError => e
$log.error('Failed to download media file: %s' % e)
end
filename = case
when response.nil? || !response.is_a?(Hash)
Expand Down

0 comments on commit 6a28e0d

Please sign in to comment.