Skip to content
Merged

Dev #181

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-cmd-meta/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/example-app-query/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-app</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-leave/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/example-domain-user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-domain</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/example-infra-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>example-infra</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion example/example-infra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion example/example-interface/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-example</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
</parent>

<artifactId>example-interface</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.codingapi.example.api.domain;

import com.codingapi.springboot.framework.dto.response.Response;
import com.codingapi.springboot.framework.exception.LocaleMessageException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/open/error")
public class ErrorController {

@GetMapping("/error1")
public Response error1(){
throw new LocaleMessageException("error1");
}

@GetMapping("/error2")
public Response error2(){
throw new LocaleMessageException("error2","error 2 message");
}

@GetMapping("/error3")
public Response error3(){
throw new LocaleMessageException("error3",new Object[]{"my is arg"});
}
}
2 changes: 1 addition & 1 deletion example/example-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-example</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.31</version>
<version>3.4.32</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 2 additions & 0 deletions example/example-server/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error1= Error 1
error3= Error 3 {0}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error1= 错误 1
error3= 错误 3 {0}
2 changes: 1 addition & 1 deletion example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</parent>

<artifactId>springboot-example</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>

<name>springboot-example</name>
<description>springboot-example project for Spring Boot</description>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>

<url>https://github.com/codingapi/springboot-framewrok</url>
<name>springboot-parent</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-authorization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
</parent>

<name>springboot-starter-data-authorization</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-data-fast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.31</version>
<version>3.4.32</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-flow/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.31</version>
<version>3.4.32</version>
</parent>

<name>springboot-starter-flow</name>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter-security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<artifactId>springboot-parent</artifactId>
<groupId>com.codingapi.springboot</groupId>
<version>3.4.31</version>
<version>3.4.32</version>
</parent>

<artifactId>springboot-starter-security</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion springboot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.codingapi.springboot</groupId>
<artifactId>springboot-parent</artifactId>
<version>3.4.31</version>
<version>3.4.32</version>
</parent>
<artifactId>springboot-starter</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,48 @@ public LocaleMessageException(String errCode, String errMessage, Throwable cause
this.errMessage = errMessage;
}

public LocaleMessageException(String errCode, Throwable cause) {
public LocaleMessageException(String errCode,Throwable cause) {
super(MessageContext.getInstance().getErrorMsg(errCode), cause);
this.errCode = errCode;
this.errMessage = getMessage();
}


public LocaleMessageException(String errCode,Object[] args, Throwable cause) {
super(MessageContext.getInstance().getErrorMsg(errCode,args), cause);
this.errCode = errCode;
this.errMessage = getMessage();
}

public LocaleMessageException(String errCode, String errMessage) {
super(errMessage);
this.errCode = errCode;
this.errMessage = errMessage;
}

public LocaleMessageException(String errCode,Object[] args) {
super(MessageContext.getInstance().getErrorMsg(errCode,args));
this.errCode = errCode;
this.errMessage = getMessage();
}

public LocaleMessageException(String errCode) {
super(MessageContext.getInstance().getErrorMsg(errCode));
this.errCode = errCode;
this.errMessage = getMessage();
}


/**
* 占位符异常,在message.properties中配置错误信息,占位符参数从0开始实例如下
* error3= 错误 3 {0} {1}
* @param errCode 错误码
* @param args 占位符参数
* @return 异常
*/
public static LocaleMessageException of(String errCode, Object ...args) {
return new LocaleMessageException(errCode, args);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ void setExceptionLocaleMessage(LocaleMessage localeMessage) {
}

public String getErrorMsg(String errCode) {
return localeMessage.getMessage(errCode);
return this.getErrorMsg(errCode,null);
}


public String getErrorMsg(String errCode,Object[] args) {
return localeMessage.getMessage(errCode,args);
}

}