Code Explainers
Code explainers tagged #error-handling
php
<?php namespace App\Support;
Retry with exponential backoff in PHP
retry
exponential-backoff
error-handling
Intermediate
7 steps
typescript
import { inject } from '@angular/core'; import { ResolveFn, Router, ActivatedRouteSnapshot } from '@angular/router'; import { catchError, of, EMPTY } from 'rxjs'; import { Article } from './models/article';
Prefetching route data with an Angular resolver
route-resolver
dependency-injection
rxjs
Intermediate
6 steps
python
from itertools import islice from typing import Iterable, Iterator, TypeVar T = TypeVar("T")
Batching an iterable for bulk indexing
generators
batching
lazy-evaluation
Intermediate
7 steps
php
<?php declare(strict_types=1);
Validating registration input with filter_var
validation
sanitization
filter_var
Intermediate
8 steps
rust
use axum::{ http::StatusCode, response::{IntoResponse, Response}, Json,
How a custom error type maps to HTTP in Axum
error-handling
enums
trait-implementation
Intermediate
7 steps
java
@Service public class GitHubClient { private final WebClient webClient;
Calling the GitHub API with Spring WebClient
reactive
http-client
dependency-injection
Intermediate
7 steps
go
package main import ( "errors"
Parsing and validating CLI flags in Go
cli-parsing
validation
error-handling
Intermediate
8 steps
java
public class ThumbnailProcessor { private static final int MAX_CONCURRENCY = 4;
Bounded parallel thumbnail rendering in Java
concurrency
thread-pool
futures
Intermediate
7 steps
php
<?php namespace App\Rules;
How a custom phone validation rule works in Laravel
validation
custom-rules
dependency
Intermediate
6 steps
rust
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json}; use serde::{Deserialize, Serialize}; use uuid::Uuid;
Building a typed create_user handler in Axum
serde
extractors
sqlx
Intermediate
7 steps
go
package store import ( "database/sql"
Wrapping and inspecting errors in Go
error-handling
error-wrapping
sentinel-errors
Intermediate
8 steps
javascript
async function fetchAllPages(baseUrl, { pageSize = 100, headers = {} } = {}) { const results = []; let cursor = null;
Cursor-based pagination with fetch
pagination
async-await
fetch
Intermediate
6 steps
rust
use std::error::Error; use std::fmt; #[derive(Debug)]
Building a typed error enum in Rust
error-handling
enums
trait-implementation
Intermediate
9 steps
python
import random import time import logging from functools import wraps
A retry decorator with exponential backoff
decorators
retry
exponential-backoff
Intermediate
6 steps
rust
use std::fs::File; use std::io::{self, BufRead, BufReader}; use std::path::Path;
Buffered log scanning in Rust
buffered-io
error-handling
streaming
Intermediate
9 steps
go
package middleware import ( "errors"
Centralized error handling in Gin
middleware
error-handling
custom-errors
Intermediate
8 steps
python
import os import tempfile from pathlib import Path from typing import Union
How atomic file writes work in Python
atomicity
filesystem
durability
Advanced
7 steps
rust
use axum::{ extract::FromRequestParts, http::{request::Parts, StatusCode, header::AUTHORIZATION}, };
How a JWT extractor works in Axum
authentication
jwt
extractors
Intermediate
8 steps