Code Explainers

Code explainers tagged #exception-handling

python
from functools import wraps
import asyncio
 
from fastapi import APIRouter, FastAPI, Request

Per-route request timeouts in FastAPI

decorators async timeouts
Intermediate 6 steps
java
@RestControllerAdvice
public class GlobalExceptionHandler {
 
    private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);

Centralized error handling in Spring

exception-handling problemdetail rest-api
Intermediate 7 steps
java
@RestController
@RequestMapping("/api/users")
public class UserController {
 

Bean Validation in a Spring REST controller

validation rest-api exception-handling
Intermediate 9 steps
python
class FileManager:
    """A context manager that safely opens and closes a file."""
 
    def __init__(self, path, mode="r"):

Writing context managers in Python

context-managers resource-management exception-handling
Intermediate 6 steps