mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 17:08:34 +00:00
Rescue redis exceptions
This commit is contained in:
parent
df612ac09d
commit
d61b4826a5
1 changed files with 23 additions and 15 deletions
|
|
@ -13,26 +13,34 @@ class RedisQueryService
|
|||
|
||||
def process
|
||||
|
||||
error = nil
|
||||
password = source_options["password"]
|
||||
password = nil if password.blank?
|
||||
|
||||
if $connections.include? data_source.id
|
||||
connection = $connections[data_source.id][:connection]
|
||||
else
|
||||
connection = Redis.new(
|
||||
host: source_options["host"],
|
||||
port: source_options["port"],
|
||||
user: source_options["username"],
|
||||
password: password
|
||||
)
|
||||
begin
|
||||
|
||||
$connections[data_source.id] = { connection: connection }
|
||||
if $connections.include? data_source.id
|
||||
connection = $connections[data_source.id][:connection]
|
||||
else
|
||||
connection = Redis.new(
|
||||
host: source_options["host"],
|
||||
port: source_options["port"],
|
||||
user: source_options["username"],
|
||||
password: password
|
||||
)
|
||||
|
||||
$connections[data_source.id] = { connection: connection }
|
||||
end
|
||||
|
||||
query_text = options["query"]
|
||||
|
||||
result = connection.call(query_text.split(" "))
|
||||
|
||||
rescue => e
|
||||
puts e
|
||||
error = e.message
|
||||
end
|
||||
|
||||
query_text = options["query"]
|
||||
|
||||
result = connection.call(query_text.split(" "))
|
||||
|
||||
{ status: 'success', data: result }
|
||||
{ status: error ? 'error' : 'success', data: result, error: error }
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue