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.
		
		
		
		
			
				
					51 lines
				
				1.4 KiB
			
		
		
			
		
	
	
					51 lines
				
				1.4 KiB
			| 
											3 years ago
										 | package com.ynxbd.common.helper.common;
 | ||
|  | 
 | ||
|  | 
 | ||
|  | import lombok.extern.slf4j.Slf4j;
 | ||
|  | import org.slf4j.Logger;
 | ||
|  | import org.slf4j.LoggerFactory;
 | ||
|  | 
 | ||
|  | /**
 | ||
|  |  * @Author wsq
 | ||
|  |  * @Date 2020/12/21 11:13
 | ||
|  |  * @Copyright @ 2020 云南新八达科技有限公司 All rights reserved.
 | ||
|  |  */
 | ||
|  | @Slf4j
 | ||
|  | public class ErrorHelper {
 | ||
|  |     public static void println(String message) {
 | ||
|  |         log.error(message);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     public static void println(Exception e) {
 | ||
|  |         println(null, e);
 | ||
|  |     }
 | ||
|  | 
 | ||
|  |     public static void println(String message, Exception e) {
 | ||
|  |         try {
 | ||
|  |             StringBuilder sb = new StringBuilder();
 | ||
|  |             if (message != null) {
 | ||
|  |                 sb.append("\n").append(message);
 | ||
|  |             }
 | ||
|  | 
 | ||
|  |             Throwable cause = e.getCause();
 | ||
|  |             StackTraceElement[] stackTrace;
 | ||
|  |             if (cause != null) {
 | ||
|  |                 stackTrace = cause.getStackTrace();
 | ||
|  |                 sb.append("\n").append(cause);
 | ||
|  |                 sb.append("\n").append(cause.getMessage());
 | ||
|  |             } else {
 | ||
|  |                 stackTrace = e.getStackTrace();
 | ||
|  |                 sb.append("\n").append(e.getMessage());
 | ||
|  |             }
 | ||
|  | 
 | ||
|  |             for (StackTraceElement stackTraceElement : stackTrace) {
 | ||
|  |                 sb.append("\n").append(stackTraceElement);
 | ||
|  |             }
 | ||
|  |             log.error(sb.toString());
 | ||
|  |         } catch (Exception err) {
 | ||
|  |             log.error(err.getMessage());
 | ||
|  |         }
 | ||
|  |     }
 | ||
|  | 
 | ||
|  | }
 |