-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Handling pluginNot found Issue
- Loading branch information
1 parent
0a6f263
commit a48ff02
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...in/src/main/java/com/example/plugin/strategyplugin/exception/PluginNotFoundException.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,27 @@ | ||
package com.example.plugin.strategyplugin.exception; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ProblemDetail; | ||
import org.springframework.web.ErrorResponseException; | ||
|
||
import java.net.URI; | ||
import java.time.Instant; | ||
|
||
public class PluginNotFoundException extends ErrorResponseException { | ||
public PluginNotFoundException(String message) { | ||
super( | ||
HttpStatus.BAD_REQUEST, | ||
asProblemDetail(message), | ||
null); | ||
} | ||
|
||
private static ProblemDetail asProblemDetail(String message) { | ||
ProblemDetail problemDetail = | ||
ProblemDetail.forStatusAndDetail(HttpStatus.BAD_REQUEST, message); | ||
problemDetail.setTitle("Product Not Found"); | ||
problemDetail.setType(URI.create("https://api.service.com/errors/bad-request")); | ||
problemDetail.setProperty("errorCategory", "Generic"); | ||
problemDetail.setProperty("timestamp", Instant.now()); | ||
return problemDetail; | ||
} | ||
} |
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