mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
Show proper error messages for pg query errors
This commit is contained in:
parent
efc704b17a
commit
bd470f7d01
1 changed files with 24 additions and 10 deletions
|
|
@ -22,18 +22,32 @@ class PostgresqlQueryService
|
||||||
|
|
||||||
def process
|
def process
|
||||||
|
|
||||||
connection = get_cached_connection(data_source)
|
error = false
|
||||||
connection = create_connection unless connection
|
|
||||||
|
|
||||||
query_text = ''
|
begin
|
||||||
query_text = if options['mode'] === 'gui'
|
connection = get_cached_connection(data_source)
|
||||||
send("generate_#{options['operation']}_query", options)
|
connection = create_connection unless connection
|
||||||
else
|
|
||||||
options['query']
|
|
||||||
end
|
|
||||||
|
|
||||||
result = connection.exec(query_text)
|
|
||||||
{ status: 'success', data: result.to_a }
|
query_text = ''
|
||||||
|
query_text = if options['mode'] === 'gui'
|
||||||
|
send("generate_#{options['operation']}_query", options)
|
||||||
|
else
|
||||||
|
options['query']
|
||||||
|
end
|
||||||
|
|
||||||
|
result = connection.exec(query_text)
|
||||||
|
|
||||||
|
rescue StandardError => e
|
||||||
|
puts e
|
||||||
|
error = { message: e.message }
|
||||||
|
end
|
||||||
|
|
||||||
|
if error
|
||||||
|
{ status: 'error', code: 500, message: error[:message], data: error }
|
||||||
|
else
|
||||||
|
{ status: 'success', data: result.to_a }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue