-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-2.2] Refine exception message of duplicate key (#3278)
This is an automated cherry-pick of #3219 /assign ruibaby ```release-note 优化名称重复的错误提示 ```
- Loading branch information
1 parent
6dfc19b
commit 53def5b
Showing
4 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
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
24 changes: 24 additions & 0 deletions
24
src/main/java/run/halo/app/infra/exception/DuplicateNameException.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,24 @@ | ||
package run.halo.app.infra.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.server.ResponseStatusException; | ||
|
||
public class DuplicateNameException extends ResponseStatusException { | ||
|
||
public DuplicateNameException() { | ||
this("Duplicate name detected"); | ||
} | ||
|
||
public DuplicateNameException(String reason) { | ||
this(reason, null); | ||
} | ||
|
||
public DuplicateNameException(String reason, Throwable cause) { | ||
this(reason, cause, null, null); | ||
} | ||
|
||
public DuplicateNameException(String reason, Throwable cause, String messageDetailCode, | ||
Object[] messageDetailArguments) { | ||
super(HttpStatus.BAD_REQUEST, reason, cause, messageDetailCode, messageDetailArguments); | ||
} | ||
} |
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