惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Schneier on Security
F
Fortinet All Blogs
博客园_首页
The GitHub Blog
The GitHub Blog
V
Visual Studio Blog
D
DataBreaches.Net
aimingoo的专栏
aimingoo的专栏
爱范儿
爱范儿
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
N
Netflix TechBlog - Medium
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
D
Docker
Engineering at Meta
Engineering at Meta
大猫的无限游戏
大猫的无限游戏
The Cloudflare Blog
罗磊的独立博客
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
T
The Exploit Database - CXSecurity.com
博客园 - 三生石上(FineUI控件)
量子位
The Last Watchdog
The Last Watchdog
MyScale Blog
MyScale Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Blog of Author Tim Ferriss
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
小众软件
小众软件
Cloudbric
Cloudbric
博客园 - 司徒正美
H
Help Net Security
人人都是产品经理
人人都是产品经理
Application and Cybersecurity Blog
Application and Cybersecurity Blog
L
LangChain Blog
Latest news
Latest news
M
MIT News - Artificial intelligence
T
Threat Research - Cisco Blogs
博客园 - Franky
S
Security Affairs
W
WeLiveSecurity
F
Full Disclosure
Know Your Adversary
Know Your Adversary
Google DeepMind News
Google DeepMind News
The Hacker News
The Hacker News
Cyberwarzone
Cyberwarzone
美团技术团队
PCI Perspectives
PCI Perspectives
C
Check Point Blog
Spread Privacy
Spread Privacy

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Error Handling Stops Scaling When It Is Treated as a Local Coding Habit
seeker-zuo · 2026-05-12 · via DEV Community

Error Handling Stops Scaling When It Is Treated as a Local Coding Habit

Many systems become hard to maintain later not because the business is inherently complex, but because error handling was never designed as part of the system.

At prototype stage, error handling is often just "bubble it up if something fails." But once a system enters long-term evolution, failure paths stop being local control flow. They carry retry decisions, degradation behavior, alert routing, user responses, troubleshooting context, and compatibility expectations. If errors are still just ad hoc strings, local enums, or incidental wrappers, the system becomes brittle.

From a system builder's perspective, the central question is not "how do we throw or return errors?" It is this:

How do we make errors converge for governance while preserving useful information for diagnosis?

This is the problem I have been trying to solve with what I call the Wukong Error Governance Model, and in Rust, with the orion-error crate.


The Core Tension: Governance vs. Diagnostics

Any serious error model has to satisfy two different consumers:

  • Callers need stable, finite classifications so they can retry, degrade, alert, or map boundary responses.
  • Troubleshooters need detailed, reliable information so they can find root cause.

Both are legitimate. They also pull in opposite directions.

If you expose too much low-level detail, upper layers become coupled to the exact failure shapes of databases, network libraries, filesystems, or third-party SDKs. Refactoring the lower layer breaks contracts.

If you only keep top-level business classifications, debugging loses the path: what actually failed, where it failed, what each layer added, and why the final response was produced.

That is why the real problem is not "should we wrap errors?" but:

How can errors converge for governance without collapsing for diagnostics?


Languages Give You Bricks, Not the Building

Every major language ecosystem has explored this problem:

  • Java has exceptions and error codes.
  • Go has explicit error returns, wrapping, and errors.Is / errors.As.
  • Rust has Result<T, E>, ?, enums, and a powerful type system.

These are all useful building blocks. None of them automatically give you an error architecture.

They help you express failure. They do not, by themselves, define:

  • which failures should share one stable identity,
  • which failures should become one governance class,
  • which details should stay internal,
  • which outputs should be exposed at the boundary,
  • and which decisions should be centralized instead of repeated in every handler.

That is the gap between "using error features" and "having error governance."


The Wukong Model

The core idea is simple:

Use stable contracts to make failures governable, reliable diagnostics to preserve root cause, and adaptive output to generate the right view for each receiver.

Internally, that means treating an error as two channels plus a projection step:

internal error model = contract channel + diagnostic channel
adaptive output      = boundary-specific view generated from the internal model

Enter fullscreen mode Exit fullscreen mode

The contract channel carries things like:

  • stable error identity,
  • stable classification,
  • governance attributes such as retryability or exposure level.

The diagnostic channel carries things like:

  • source / cause chain,
  • operation context,
  • structured detail,
  • lower-level failures.

Then boundary outputs such as HTTP responses, CLI output, logs, metrics, or RPC errors are produced from policy, not handcrafted independently in every endpoint.

The key is not making errors more complicated. The key is separating information that should be stable from information that should remain detailed and dynamic.


Why Rust Is a Good Fit

Rust is a strong fit for this model because it already makes failure paths explicit.

  • Result<T, E> keeps error flow in the type system.
  • enums are a natural fit for finite classification spaces.
  • match gives exhaustive handling.
  • generic carriers make it possible to reuse one structured runtime model across domains.

But Rust still does not solve governance automatically.

thiserror, anyhow, and eyre are useful. They help with type generation, propagation ergonomics, and diagnostics. They do not define stable error identity, semantic boundary rules, or centralized output policy for you.

Without those extra constraints, many Rust systems still drift into a familiar pattern:

  • some places return business enums,
  • some places pass lower-level errors through unchanged,
  • some places flatten everything into strings,
  • every handler decides status codes and messages a little differently.

That is error handling, but not yet error governance.


Five Practical Rules for Rust

1. Define reasons by semantic domain, not as one global mega-enum

Do not make one AppError own every failure in the system. Use domain-level reason types instead: RepositoryReason, OrderReason, ParserReason, and so on.

#[derive(Debug, Clone, OrionError)]
enum OrderReason {
    #[orion_error(identity = "order.submit_dependency_unavailable")]
    SubmitDependencyUnavailable,

    #[orion_error(identity = "order.invalid_state")]
    InvalidState,
}

Enter fullscreen mode Exit fullscreen mode

What stays stable is the error identity, not the message wording and not necessarily the enum name itself.

2. Structure errors at first entry

When I/O, network, database, or parse failures enter your own system, that is the moment to do three things at once:

  • choose the current-layer classification,
  • explain the current-layer failure,
  • preserve the lower-level error as source.

If you flatten the lower layer into a string first and reinterpret it later, both governance and diagnostics degrade.

3. Create a new boundary when crossing semantic domains, but preserve the lower layer

Inside one semantic domain, classification can converge. Across domains, a new semantic boundary should usually be created.

For example, a repository connection failure should not leak directly as a repository-level failure to an order service boundary. At the upper layer it may become order.submit_dependency_unavailable, while the repository failure remains preserved in the diagnostic chain.

4. Boundaries should output, not reinterpret

HTTP handlers, RPC endpoints, and CLI entry points should not each decide status codes, messages, and visibility on their own. The boundary should hand the internal error to centralized policy and receive the appropriate output view.

That is how one stable error identity leads to one consistent external behavior.

5. Test error identities, not message prose

Messages change. Wording improves. Text gets redacted or localized. Stable contracts should not depend on that.

assert_eq!(
    err.identity_snapshot().code,
    "order.submit_dependency_unavailable"
);

Enter fullscreen mode Exit fullscreen mode

If tests lock onto prose, every wording change becomes a compatibility hazard. If tests lock onto identity and policy outcomes, the contract becomes enforceable.


What orion-error Is Trying to Do

orion-error is not mainly about saving a few lines of Rust error boilerplate.

It is an attempt to make error governance in Rust operational:

Result<T, StructError<R>>

R              -> contract channel: reason / identity / category
StructError<R> -> diagnostic channel: detail / context / source chain
policy         -> boundary output decisions

Enter fullscreen mode Exit fullscreen mode

In that structure:

  • R expresses stable classification and identity,
  • StructError<R> carries diagnostic information,
  • exposure, report, and snapshot APIs project the internal model into boundary-specific views.

The point is not one clever API. The point is to give industrial Rust systems a consistent model for error propagation, compatibility, exposure, and diagnosis.


Closing Thought

Rust already gives us strong primitives for error handling. But industrial systems need more than Result, ?, and a few convenient derive macros.

They need a durable governance structure for failure paths: one that gives callers stable contracts, gives troubleshooters useful information, keeps boundary behavior consistent, and helps systems resist long-term decay.

That is why I describe orion-error as the Rust implementation of the Wukong Error Governance Model.

orion-error github repo