-
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
81e858e
commit 1553ed2
Showing
5 changed files
with
63 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const environment = { production: false, apiUrl: 'http://localhost:8888/api' }; |
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
33 changes: 33 additions & 0 deletions
33
...-analyzer/src/main/java/com/nashtech/blogs/analyzer/exception/GlobalExceptionHandler.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,33 @@ | ||
package com.nashtech.blogs.analyzer.exception; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
import org.springframework.web.context.request.WebRequest; | ||
|
||
import java.io.IOException; | ||
|
||
@ControllerAdvice | ||
public class GlobalExceptionHandler { | ||
private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class); | ||
|
||
@ExceptionHandler(Exception.class) | ||
public ResponseEntity<String> handleGlobalException(Exception ex, WebRequest request) { | ||
logger.error("Exception occurred: {}", ex.getMessage(), ex); | ||
return new ResponseEntity<>("An error occurred: " + ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); | ||
} | ||
|
||
@ExceptionHandler(IOException.class) | ||
public ResponseEntity<String> handleIOException(IOException ex, WebRequest request) { | ||
logger.error("IOException occurred: {}", ex.getMessage(), ex); | ||
return new ResponseEntity<>("An I/O error occurred: " + ex.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR); | ||
} | ||
|
||
@ExceptionHandler(PostNotFoundException.class) | ||
public ResponseEntity<String> handlePostNotFoundException(PostNotFoundException ex) { | ||
return new ResponseEntity<>(ex.getMessage(), HttpStatus.NOT_FOUND); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...s-analyzer/src/main/java/com/nashtech/blogs/analyzer/exception/PostNotFoundException.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,7 @@ | ||
package com.nashtech.blogs.analyzer.exception; | ||
|
||
public class PostNotFoundException extends RuntimeException { | ||
public PostNotFoundException(String message) { | ||
super(message); | ||
} | ||
} |