mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-17 12:21:31 +00:00
Properly rescue Timeout::Error.
The `rescue` modifier does not take an exception class to rescue.
This commit is contained in:
parent
f09bfd8a5e
commit
7b341cfc62
1 changed files with 14 additions and 12 deletions
|
@ -118,20 +118,22 @@ module Agents
|
|||
|
||||
def check
|
||||
mqtt_client.connect do |c|
|
||||
begin
|
||||
Timeout.timeout((interpolated['max_read_time'].presence || 15).to_i) {
|
||||
c.get(interpolated['topic']) do |topic, message|
|
||||
|
||||
Timeout::timeout((interpolated['max_read_time'].presence || 15).to_i) {
|
||||
c.get(interpolated['topic']) do |topic, message|
|
||||
# A lot of services generate JSON. Try that first
|
||||
payload = JSON.parse(message) rescue message
|
||||
|
||||
# A lot of services generate JSON. Try that first
|
||||
payload = JSON.parse(message) rescue message
|
||||
|
||||
create_event :payload => {
|
||||
'topic' => topic,
|
||||
'message' => payload,
|
||||
'time' => Time.now.to_i
|
||||
}
|
||||
end
|
||||
} rescue TimeoutError
|
||||
create_event :payload => {
|
||||
'topic' => topic,
|
||||
'message' => payload,
|
||||
'time' => Time.now.to_i
|
||||
}
|
||||
end
|
||||
}
|
||||
rescue Timeout::Error
|
||||
end
|
||||
|
||||
c.disconnect
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue