Added QueryException for 500 errors