公共异常处理

main
XiaoHH 2 years ago
parent 1c0b975baf
commit 0f46a24504

@ -66,6 +66,12 @@
<groupId>com.greateme</groupId>
<artifactId>verification-code-client</artifactId>
</dependency>
<!-- 公共的web模块 -->
<dependency>
<groupId>com.greateme</groupId>
<artifactId>common-web</artifactId>
</dependency>
</dependencies>
<build>

@ -23,7 +23,7 @@
<!-- 公共常量类模块 -->
<dependency>
<groupId>com.greateme</groupId>
<artifactId>common-contant</artifactId>
<artifactId>common-constant</artifactId>
</dependency>
</dependencies>

@ -10,6 +10,6 @@
</parent>
<description>公共常量类模块</description>
<artifactId>common-contant</artifactId>
<artifactId>common-constant</artifactId>
</project>

@ -16,7 +16,7 @@
<!-- 公共常量类模块 -->
<dependency>
<groupId>com.greateme</groupId>
<artifactId>common-contant</artifactId>
<artifactId>common-constant</artifactId>
</dependency>
<!-- util 工具模块 -->

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.greateme</groupId>
<artifactId>common</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<description>公共的web模块</description>
<artifactId>common-web</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- Spring Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>provided</scope>
</dependency>
<!-- 公共实体类模块 -->
<dependency>
<groupId>com.greateme</groupId>
<artifactId>common-entity</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

@ -0,0 +1,40 @@
package com.greateme.web.advice;
import com.greateme.entity.respose.ResponseEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* <p>
*
* </p>
*
* @author XiaoHH
* @version 1.0.0
* @date 2023-07-06 14:15:14
* @file CommonControllerAdvice.java
*/
@Component
@RestControllerAdvice
public class CommonControllerAdvice {
/**
*
*/
private static final Logger log = LoggerFactory.getLogger(CommonControllerAdvice.class);
/**
*
*
* @param e
* @return
*/
@ExceptionHandler(Throwable.class)
public ResponseEntity<Void> handleThrowable(Throwable e) {
log.error("接收用户请求了发生错误", e);
return ResponseEntity.error(e.getMessage());
}
}

@ -14,8 +14,9 @@
<modules>
<module>common-entity</module>
<module>common-util</module>
<module>common-contant</module>
<module>common-constant</module>
<module>common-annotation</module>
<module>common-web</module>
</modules>
<artifactId>common</artifactId>

@ -67,7 +67,7 @@
<!-- 公共常量类模块 -->
<dependency>
<groupId>com.greateme</groupId>
<artifactId>common-contant</artifactId>
<artifactId>common-constant</artifactId>
<version>${online-taxi-public.version}</version>
</dependency>
@ -98,6 +98,13 @@
<artifactId>common-annotation</artifactId>
<version>${online-taxi-public.version}</version>
</dependency>
<!-- 公共的web模块 -->
<dependency>
<groupId>com.greateme</groupId>
<artifactId>common-web</artifactId>
<version>${online-taxi-public.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>

@ -72,6 +72,12 @@
<groupId>com.greateme</groupId>
<artifactId>common-annotation</artifactId>
</dependency>
<!-- 公共的web模块 -->
<dependency>
<groupId>com.greateme</groupId>
<artifactId>common-web</artifactId>
</dependency>
</dependencies>
<build>

@ -66,6 +66,12 @@
<groupId>com.greateme</groupId>
<artifactId>common-annotation</artifactId>
</dependency>
<!-- 公共的web模块 -->
<dependency>
<groupId>com.greateme</groupId>
<artifactId>common-web</artifactId>
</dependency>
</dependencies>
<build>

Loading…
Cancel
Save