-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or requesthotfix
Description
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
-
App.init()- Add context for each subsystem initialization -
World.init()- Distinguish between storage, streamer, renderer init failures -
ChunkMesh.build()- Report which chunk failed meshing - RHI operations - Include resource type and size in errors
- Shader compilation - Include shader name and error message
Benefits
- Faster debugging when errors occur
- Clearer error messages for users
- Easier to diagnose issues in production
Acceptance Criteria
- Critical initialization paths have detailed error logging
- Error messages include file and line information
- Debug builds include full stack traces
- Document error handling strategy
- Tests still pass
Related Files
src/game/app.zigsrc/world/world.zigsrc/engine/core/log.zigsrc/engine/graphics/rhi.zig
Estimated Effort
Medium (requires auditing all error paths)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingdocumentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or requesthotfix