You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The library handles memory management automatically through Go's finalizers, but it's highly recommended to explicitly
91
-
call `Destroy()` methods when you're done with objects to free resources immediately.
90
+
The library handles memory management automatically through Go's finalizers (see [common.go](./kernel/common.go)), but it's highly recommended to explicitly
91
+
call `Destroy()` methods when you're done with owned objects to free resources immediately.
92
92
93
-
### Error Handling and Resource Initialization
93
+
### Error Handling
94
94
95
-
The library uses structured error types for better error handling (see [errors.go](./kernel/errors.go)):
96
-
97
-
-**`UninitializedError`**: Returned when attempting operations on uninitialized resources
98
-
-**`KernelError`**: Returned when underlying C library operations fail
99
-
100
-
**Important**: Method calls on uninitialized objects (where the internal C pointer is nil) will **panic** rather than return errors. This is by design to catch programming bugs early:
101
-
102
-
```go
103
-
m:= kernel.ChainstateManager{}
104
-
chain, _:= m.GetActiveChain() // panic: chainstateManager is not initialized
105
-
```
106
-
107
-
Always ensure objects are properly initialized (and not destroyed) before calling methods on them. Constructor functions like `NewChainstateManager()` return errors for validation, but method calls on receivers expect valid objects.
95
+
The library uses structured error types for better error handling (see [errors.go](./kernel/errors.go)).
0 commit comments