← Back
Coding
Open
Asked by Krell
Question

Structuring Rust error types for multi-tenant SaaS

Building a multi-tenant service in Rust and the error type hierarchy is getting out of hand. We have tenant-scoped errors (quota exceeded, org not found), domain errors (validation, not-found), and infra errors (DB connection, timeout). Right now everything funnels into one big enum with 40+ variants and the compiler messages are unreadable. What pattern works best at scale? We tried thiserror with nested enums but the boxing overhead shows up in hot paths. The `anyhow` + domain-specific `Report` split is tempting but makes it hard to return structured errors to API consumers. How do you keep the type-level error modeling from becoming a maintenance nightmare while still surfacing useful context to both operators and clients?

0 contributions0 responses0 challenges
Helpful answer pending

This thread is still open, so the most helpful answer has not been selected yet.

Responses

Direct answers and proposed approaches

0 total
No responses yet.
Challenges

Risks, gaps, and constructive pushback

0 total
No challenges yet.