generated from pagopa/template-java-spring-microservice
-
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
Showing
16 changed files
with
171 additions
and
179 deletions.
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
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
20 changes: 0 additions & 20 deletions
20
src/main/java/it/gov/pagopa/wispconverter/exception/AppClientException.java
This file was deleted.
Oops, something went wrong.
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: 17 additions & 7 deletions
24
src/main/java/it/gov/pagopa/wispconverter/exception/AppException.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 |
---|---|---|
@@ -1,30 +1,40 @@ | ||
package it.gov.pagopa.wispconverter.exception; | ||
|
||
import lombok.Getter; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.text.MessageFormat; | ||
|
||
@Getter | ||
public class AppException extends RuntimeException { | ||
|
||
private final AppErrorCodeMessageEnum error; | ||
private final transient Object[] args; | ||
private final String reason; | ||
// private final String detail; | ||
|
||
public AppException(AppErrorCodeMessageEnum error, String reason, Object... args) { | ||
super(reason); | ||
public AppException(AppErrorCodeMessageEnum error, Object... args) { | ||
super(composeMessage(error, getArgsOrNull(args))); | ||
this.error = error; | ||
this.reason = reason; | ||
this.args = getArgsOrNull(args); | ||
// this.detail = composeMessage(error, getArgsOrNull(args)); | ||
} | ||
|
||
public AppException(Throwable cause, AppErrorCodeMessageEnum error, String reason, Object... args) { | ||
super(reason, cause); | ||
public AppException(Throwable cause, AppErrorCodeMessageEnum error, Object... args) { | ||
super(composeMessage(error, getArgsOrNull(args)), cause); | ||
this.error = error; | ||
this.reason = reason; | ||
this.args = getArgsOrNull(args); | ||
// this.detail = composeMessage(error, getArgsOrNull(args)); | ||
} | ||
|
||
private static Object[] getArgsOrNull(Object... args) { | ||
return args.length > 0 ? args.clone() : null; | ||
} | ||
|
||
private static String composeMessage(AppErrorCodeMessageEnum error, Object[] args){ | ||
if(error.getDetail() != null){ | ||
return MessageFormat.format(error.getDetail(), args); | ||
} | ||
return null; | ||
} | ||
|
||
} |
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
Oops, something went wrong.