(final Exception e)
| 179 | /** This has to be attached to callbacks or we may never respond to clients */ |
| 180 | class ErrorCB implements Callback<Object, Exception> { |
| 181 | public Object call(final Exception e) throws Exception { |
| 182 | Throwable ex = e; |
| 183 | try { |
| 184 | LOG.error("Query exception: ", e); |
| 185 | if (ex instanceof DeferredGroupException) { |
| 186 | ex = e.getCause(); |
| 187 | while (ex != null && ex instanceof DeferredGroupException) { |
| 188 | ex = ex.getCause(); |
| 189 | } |
| 190 | if (ex == null) { |
| 191 | LOG.error("The deferred group exception didn't have a cause???"); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | if (ex instanceof RpcTimedOutException) { |
| 196 | query_stats.markSerialized(HttpResponseStatus.REQUEST_TIMEOUT, ex); |
| 197 | query.badRequest(new BadRequestException( |
| 198 | HttpResponseStatus.REQUEST_TIMEOUT, ex.getMessage())); |
| 199 | query_exceptions.incrementAndGet(); |
| 200 | } else if (ex instanceof HBaseException) { |
| 201 | query_stats.markSerialized(HttpResponseStatus.FAILED_DEPENDENCY, ex); |
| 202 | query.badRequest(new BadRequestException( |
| 203 | HttpResponseStatus.FAILED_DEPENDENCY, ex.getMessage())); |
| 204 | query_exceptions.incrementAndGet(); |
| 205 | } else if (ex instanceof QueryException) { |
| 206 | query_stats.markSerialized(((QueryException)ex).getStatus(), ex); |
| 207 | query.badRequest(new BadRequestException( |
| 208 | ((QueryException)ex).getStatus(), ex.getMessage())); |
| 209 | query_exceptions.incrementAndGet(); |
| 210 | } else if (ex instanceof BadRequestException) { |
| 211 | query_stats.markSerialized(((BadRequestException)ex).getStatus(), ex); |
| 212 | query.badRequest((BadRequestException)ex); |
| 213 | query_invalid.incrementAndGet(); |
| 214 | } else if (ex instanceof NoSuchUniqueName) { |
| 215 | query_stats.markSerialized(HttpResponseStatus.BAD_REQUEST, ex); |
| 216 | query.badRequest(new BadRequestException(ex)); |
| 217 | query_invalid.incrementAndGet(); |
| 218 | } else { |
| 219 | query_stats.markSerialized(HttpResponseStatus.INTERNAL_SERVER_ERROR, ex); |
| 220 | query.badRequest(new BadRequestException(ex)); |
| 221 | query_exceptions.incrementAndGet(); |
| 222 | } |
| 223 | |
| 224 | } catch (RuntimeException ex2) { |
| 225 | LOG.error("Exception thrown during exception handling", ex2); |
| 226 | query_stats.markSerialized(HttpResponseStatus.INTERNAL_SERVER_ERROR, ex2); |
| 227 | query.sendReply(HttpResponseStatus.INTERNAL_SERVER_ERROR, |
| 228 | ex2.getMessage().getBytes()); |
| 229 | query_exceptions.incrementAndGet(); |
| 230 | } |
| 231 | return null; |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | /** |
nothing calls this directly
no test coverage detected