Problem
Many functions in the codebase use Zig's error unions with generic error types, making it difficult to trace the origin of errors. Long try chains can obscure where errors actually occur.
Current State
Example from app.zig:
const rhi = try rhi_vulkan.createRHI(allocator, wm.window, null, ...);
errdefer rhi.deinit();
try rhi.init(allocator, null);
When an error occurs, you only see the error type (e.g., error.OutOfMemory) without context about which specific call failed.
Proposed Solution
Improve error handling in two ways:
Option 1: Rich Error Types
Create error structs with context including file, line, and message.
Option 2: Logging with Context
Add detailed logging at error sites using @src() for file:line info.
Option 3: Zig Error Return Traces
Use @errorReturnTrace() in debug builds to capture stack traces.
Specific Areas to Improve
Benefits
- Faster debugging when errors occur
- Clearer error messages for users
- Easier to diagnose issues in production
Acceptance Criteria
Related Files
src/game/app.zig
src/world/world.zig
src/engine/core/log.zig
src/engine/graphics/rhi.zig
Estimated Effort
Medium (requires auditing all error paths)
Problem
Many functions in the codebase use Zig's error unions with generic error types, making it difficult to trace the origin of errors. Long
trychains can obscure where errors actually occur.Current State
Example from app.zig:
When an error occurs, you only see the error type (e.g.,
error.OutOfMemory) without context about which specific call failed.Proposed Solution
Improve error handling in two ways:
Option 1: Rich Error Types
Create error structs with context including file, line, and message.
Option 2: Logging with Context
Add detailed logging at error sites using @src() for file:line info.
Option 3: Zig Error Return Traces
Use
@errorReturnTrace()in debug builds to capture stack traces.Specific Areas to Improve
App.init()- Add context for each subsystem initializationWorld.init()- Distinguish between storage, streamer, renderer init failuresChunkMesh.build()- Report which chunk failed meshingBenefits
Acceptance Criteria
Related Files
src/game/app.zigsrc/world/world.zigsrc/engine/core/log.zigsrc/engine/graphics/rhi.zigEstimated Effort
Medium (requires auditing all error paths)