Skip to content

wtopps/java-common-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

java-common-utils

java common utils library

一个简单的Java通用工具类,目前的设想,包括简化异常处理工具、简易限流处理工具等

ExceptionHandler, 目标简化try catch的代码冗余度

try {
  // dosomething...
} catch (Exception e) {
  log.error(e);
}

简化为

ExceptionHandler.ignoreExceptionWithErrorMsg(() -> {
  // dosomething....            
}, "exec error");
try {
  // dosomething...
} catch (Exception e) {
  log.error(e);
  throws new MyException("执行错误");
}

简化为

ExceptionHandler.runtimeException(() -> {
   // dosomething...
}, "exec error");
try {
  // dosomething...
} catch (Exception e) {
  log.error(e);
  // if exception happen, then exec something...
  // dosomething
  log.error("exec error");
}

简化为

ThrowsHandler.run(() -> {
    // dosomething...
   })
   .whenExceptionThen(() -> //dosomethings...)
   .logThrowable("exec error");
try {
  // dosomething...
} catch (Exception e) {
  log.error(e);
  // if exception happen, then exec something...
  // dosomething
  log.error("exec error");
  throws new MyException("exec error");
}

简化为

ThrowsHandler.run(() -> {
    // dosomething...
   })
   .whenExceptionThen(() -> //dosomethings...)
   .runtimeExp("exec error");

About

java common utils library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages