-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formatting responses for /search (dishes)
- Loading branch information
1 parent
8044ed0
commit a992124
Showing
7 changed files
with
95 additions
and
8 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
19 changes: 19 additions & 0 deletions
19
backend/src/main/java/com/group1/cuisines/dto/DishResponseDto.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,19 @@ | ||
package com.group1.cuisines.dto; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class DishResponseDto { | ||
private String id; | ||
private String name; | ||
private String image; | ||
private String description; | ||
private String countries; | ||
private String ingredients; | ||
private String foodTypes; | ||
private String cuisines; | ||
} |
26 changes: 26 additions & 0 deletions
26
backend/src/main/java/com/group1/cuisines/exceptions/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,26 @@ | ||
package com.group1.cuisines.exceptions; | ||
|
||
import com.group1.cuisines.dao.response.ApiResponse; | ||
import org.springframework.boot.context.config.ConfigDataResourceNotFoundException; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ExceptionHandler; | ||
|
||
@ControllerAdvice | ||
public class GlobalExceptionHandler { | ||
|
||
@ExceptionHandler(Exception.class) | ||
public ResponseEntity<ApiResponse<String>> handleException(Exception e) { | ||
ApiResponse<String> response = new ApiResponse<>(500, "An unexpected error occurred: " + e.getMessage(), null); | ||
return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); | ||
} | ||
|
||
@ExceptionHandler(ResourceNotFoundException.class) | ||
public ResponseEntity<ApiResponse<String>> handleResourceNotFoundException(ResourceNotFoundException e) { | ||
ApiResponse<String> response = new ApiResponse<>(400, e.getMessage(), null); | ||
return new ResponseEntity<>(response, HttpStatus.NOT_FOUND); | ||
} | ||
|
||
|
||
} |
7 changes: 7 additions & 0 deletions
7
backend/src/main/java/com/group1/cuisines/exceptions/ResourceNotFoundException.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.group1.cuisines.exceptions; | ||
|
||
public class ResourceNotFoundException extends RuntimeException { | ||
public ResourceNotFoundException(String message) { | ||
super(message); | ||
} | ||
} |
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