forked from zhangkaitao/es
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd85ac3
commit 8272927
Showing
157 changed files
with
4,439 additions
and
2,380 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
common/src/main/java/com/sishuok/es/common/exception/BaseException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* Copyright (c) 2005-2012 https://github.com/zhangkaitao | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
*/ | ||
package com.sishuok.es.common.exception; | ||
|
||
import com.sishuok.es.common.utils.MessageUtils; | ||
import com.sishuok.es.common.utils.SpringUtils; | ||
import org.springframework.context.MessageSource; | ||
import org.springframework.util.StringUtils; | ||
|
||
import java.util.Locale; | ||
|
||
/** | ||
* 基础异常 | ||
* <p>User: Zhang Kaitao | ||
* <p>Date: 13-3-11 下午8:19 | ||
* <p>Version: 1.0 | ||
*/ | ||
public class BaseException extends RuntimeException { | ||
|
||
//所属模块 | ||
private String module; | ||
|
||
/** | ||
* 错误码 | ||
*/ | ||
private String code; | ||
|
||
/** | ||
* 错误码对应的参数 | ||
*/ | ||
private Object[] args; | ||
|
||
/** | ||
* 错误消息 | ||
*/ | ||
private String defaultMessage; | ||
|
||
|
||
public BaseException(String module, String code, Object[] args, String defaultMessage) { | ||
this.module = module; | ||
this.code = code; | ||
this.args = args; | ||
this.defaultMessage = defaultMessage; | ||
} | ||
|
||
public BaseException(String module, String code, Object[] args) { | ||
this(module, code, args, null); | ||
} | ||
|
||
public BaseException(String module, String defaultMessage) { | ||
this(module, null, null, defaultMessage); | ||
} | ||
|
||
public BaseException(String code, Object[] args) { | ||
this(null, code, args, null); | ||
} | ||
|
||
public BaseException(String defaultMessage) { | ||
this(null, null, null, defaultMessage); | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
String message = null; | ||
if(StringUtils.hasLength(code)) { | ||
message = MessageUtils.message(code, args); | ||
} | ||
if(message == null) { | ||
message = defaultMessage; | ||
} | ||
return message; | ||
} | ||
|
||
|
||
public String getModule() { | ||
return module; | ||
} | ||
|
||
public String getCode() { | ||
return code; | ||
} | ||
|
||
public Object[] getArgs() { | ||
return args; | ||
} | ||
|
||
public String getDefaultMessage() { | ||
return defaultMessage; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ | |
|
||
<context:component-scan base-package="com.sishuok.es.common.utils"></context:component-scan> | ||
|
||
|
||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.