Code Explainers
Code explainers tagged #error-handling
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
go
package main import ( "bufio"
Counting matching lines in Go with bufio
file-io
buffered-scanning
error-handling
Intermediate
4 steps
rust
use axum::{extract::Form, http::StatusCode, response::{IntoResponse, Response}, Json}; use serde::Deserialize; use serde_json::json; use std::collections::HashMap;
Validating a signup form in Axum
form-validation
deserialization
error-handling
Intermediate
8 steps
javascript
const fs = require('fs'); const path = require('path'); router.get('/downloads/:name', (req, res, next) => {
Streaming file downloads in Express
streaming
backpressure
file-download
Advanced
9 steps
ruby
module Retryable class RetriesExhausted < StandardError; end RETRYABLE_ERRORS = [
Exponential backoff retries in Ruby
retry-logic
exponential-backoff
error-handling
Intermediate
7 steps
javascript
async function pollJobUntilComplete(jobId, { interval = 2000, timeout = 60000, signal } = {}) { const deadline = Date.now() + timeout; while (true) {
Polling a job until it finishes in JavaScript
polling
async-await
abortsignal
Intermediate
6 steps
go
package handlers import ( "net/http"
Rendering HTML pages with Gin handlers
http-handlers
templating
error-handling
Beginner
8 steps