You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
548 B
24 lines
548 B
package com.fr.base.function; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
/** |
|
* 可抛出异常的 Runnable |
|
* |
|
* created by Harrison on 2022/05/24 |
|
**/ |
|
public interface ThrowableRunnable<T extends Exception> { |
|
|
|
void run() throws T; |
|
|
|
static <T extends Exception> Runnable toRunnable(ThrowableRunnable<T> runnable) { |
|
|
|
return () -> { |
|
try { |
|
runnable.run(); |
|
} catch (Exception e) { |
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
} |
|
}; |
|
} |
|
}
|
|
|