Plse add an option to redisplay the "old" error-div if sth. failed.
If you have a long (text) sql-query failing, you get an totally undersized js-error dialog which is hard to read & closes on an accidential click.
add an div on top of the page, containing the error, have the query-section (with inline,...) under it. Having this, you can see the error on full monitor width, second you can change the query to make it work & maybe you can put a structured output above it. Sometimes only a quote or brace is missing, which you must find.