Skip to content

Commit

Permalink
SQL erors are returned as json
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Aug 28, 2012
1 parent c175461 commit 4607fb3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ckanext/datastore/db.py
@@ -1,4 +1,5 @@
import sqlalchemy
from sqlalchemy.exc import ProgrammingError
import ckan.plugins as p
import psycopg2.extras
import json
Expand Down Expand Up @@ -592,6 +593,15 @@ def search_sql(context, data_dict):
)
return format_results(context, results, data_dict)

except ProgrammingError, e:
raise p.toolkit.ValidationError({
'query': [str(e)],
'info': {
'statement': [e.statement],
'params': [e.params],
'orig': [str(e.orig)]
}
})
except Exception, e:
if 'due to statement timeout' in str(e):
raise p.toolkit.ValidationError({
Expand Down

0 comments on commit 4607fb3

Please sign in to comment.