public static <E extends RuntimeException> void checkNotEmpty(Map<?, ?> objects, E ex) { check(() -> objects == null || objects.size() == 0, ex); }
throw Dew.E.e(StandardCode.NOT_FOUND.toString(), new RuntimeException("Need @PkColumn or @CodeColumn field.")); values.remove(entityClassInfo.codeFieldNameOpt.get()); } else { throw Dew.E.e(StandardCode.BAD_REQUEST.toString(), new RuntimeException("Need Private Key or Code value.")); throw Dew.E.e(StandardCode.BAD_REQUEST.toString(), new RuntimeException("Not Null check fail."));
public static <E extends RuntimeException> void checkNotEmpty(Iterable<?> objects, E ex) { check(() -> objects == null || !objects.iterator().hasNext(), ex); }
public static <E extends RuntimeException> void checkNotNull(Object obj, E ex) { check(() -> obj == null, ex); }
/** * 异常处理-重用Http状态 * * @param code 异常编码 * @param ex 异常类型 * @param customHttpCode 自定义Http状态码 */ public static <E extends Throwable> E e(String code, E ex, StandardCode customHttpCode) { return e(code, ex, Integer.valueOf(customHttpCode.toString())); }
/** * 抛出不符合预期异常 * * @param notExpected 不符合预期的情况 */ public static void check(boolean notExpected) { check(() -> notExpected); }
@PutMapping("offline") public String generateOfflineDoc(@Validated @RequestBody OfflineDocGenerateReq request) throws Exception { List<String> swaggerJsonUrls = (request.getSwaggerJsonUrls() == null || request.getSwaggerJsonUrls().isEmpty()) ? fetchSwaggerJsonUrlsFun.get() : request.getSwaggerJsonUrls(); Resp<String> result = docService.generateOfflineDoc(request.getDocName(), request.getDocDesc(), request.getVisitUrls(), swaggerJsonUrls); if (result.ok()) { return result.getBody(); } else { throw Dew.E.e(result.getCode(), new Exception(result.getMessage())); } }
/** * 抛出不符合预期异常 * * @param notExpected 不符合预期的情况 * @param ex 异常 */ public static <E extends RuntimeException> void check(boolean notExpected, E ex) { check(() -> notExpected, ex); }
/** * 异常处理-重用Http状态 * * @param code 异常编码 * @param ex 异常类型 */ public static <E extends Throwable> E e(String code, E ex) { return e(code, ex, -1); }