|
3 | 3 | from geojson_pydantic import GeometryCollection, Polygon |
4 | 4 | from loguru import logger |
5 | 5 |
|
| 6 | +from app.error import DispatcherException, ErrorResponse, InternalException |
| 7 | +from app.middleware.error_handling import get_dispatcher_error_response |
6 | 8 | from app.schemas.tiles import GridTypeEnum, TileRequest |
7 | 9 | from app.services.tiles.base import split_polygon_by_grid |
8 | 10 |
|
|
54 | 56 | } |
55 | 57 | } |
56 | 58 | }, |
57 | | - } |
| 59 | + }, |
| 60 | + InternalException.http_status: { |
| 61 | + "description": "Internal server error", |
| 62 | + "model": ErrorResponse, |
| 63 | + "content": { |
| 64 | + "application/json": { |
| 65 | + "example": get_dispatcher_error_response( |
| 66 | + InternalException(), "request-id" |
| 67 | + ) |
| 68 | + } |
| 69 | + }, |
| 70 | + }, |
58 | 71 | }, |
59 | 72 | ) |
60 | 73 | def split_in_tiles( |
@@ -90,11 +103,12 @@ def split_in_tiles( |
90 | 103 | try: |
91 | 104 | logger.debug(f"Splitting tiles in a {payload.grid} formation") |
92 | 105 | return split_polygon_by_grid(payload.aoi, payload.grid) |
| 106 | + except DispatcherException as de: |
| 107 | + raise de |
93 | 108 | except Exception as e: |
94 | | - logger.exception( |
95 | | - f"An error occurred while calculating tiles for {payload.grid}" |
| 109 | + logger.error( |
| 110 | + f"An error occurred while calculating tiles for {payload.grid}: {e}" |
96 | 111 | ) |
97 | | - raise HTTPException( |
98 | | - status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, |
99 | | - detail=f"An error occurred while calculating tiles for {payload.grid}: {e}", |
| 112 | + raise InternalException( |
| 113 | + message=f"An error occurred while calculating tiles for {payload.grid}" |
100 | 114 | ) |
0 commit comments