|
@@ -1,6 +1,8 @@
|
|
|
package com.winhc.fast.query.configuration;
|
|
|
|
|
|
+import com.alibaba.lindorm.client.exception.NotServingRegionException;
|
|
|
import com.winhc.fast.query.vo.ResponseVo;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
@@ -13,11 +15,25 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@RestControllerAdvice
|
|
|
+@AllArgsConstructor
|
|
|
public class GlobalExceptionHandler {
|
|
|
+ private HbaseHealthIndicator hbaseHealthIndicator;
|
|
|
+
|
|
|
@ResponseStatus(HttpStatus.OK)
|
|
|
@ExceptionHandler(value = Exception.class)
|
|
|
public ResponseVo handleBadRequest(Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
return ResponseVo.failure(e.getMessage());
|
|
|
}
|
|
|
+
|
|
|
+ @ResponseStatus(HttpStatus.OK)
|
|
|
+ @ExceptionHandler(value = NotServingRegionException.class)
|
|
|
+ public ResponseVo handleBadRequest(NotServingRegionException e) {
|
|
|
+ log.error("发现hbase异常!");
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
+ hbaseHealthIndicator.putErrorInfo(e);
|
|
|
+ return ResponseVo.failure(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|