Errors and logging¶
A value that cannot be read is an error¶
Everything in this SDK that can fail to answer returns a Result, and the error says
why. Nothing returns a plausible default.
| Rust | |
|---|---|
The reason is one specific incident. An event in a custom dimension could not be read for
its dimension, the consumer wrote unwrap_or(0), and every such event was treated as
happening in the overworld. Land protection then refused inside the overworld and allowed
everything everywhere else. Nothing was logged, and the behaviour looked deliberate.
When you do not know, refuse.
When a decision cannot answer¶
A decision that might fail to answer does not return a bare bool. Collapsed into the
same false a caller can only guess; collapsed into true it is a security hole.
So Ok(None) and Err mean different things throughout:
| Rust | |
|---|---|
Identity¶
PlayerSel::Name is not an identity. When the host cannot match an account name it falls
back to the display name, and another mod can change a display name. A player who sets
theirs to the account name of an offline player redirects every by-name call onto
themselves.
| Rust | |
|---|---|
sel.is_stable() reports which kind you are holding. A permission decision that receives
false should take care.
Logging¶
| Rust | |
|---|---|
The line comes out under your mod's name, not under [pier].
A log line has to answer what to do about it. "subscribe failed" does not; the id not
existing on this BDS version, with the nearby ids from the registry, does. Pier's own
messages follow that rule, so read them rather than skimming for the word error.
The success path logs nothing at info level.
Panics¶
A panic must not cross the boundary back into the server, so every callback the SDK hands to the host is wrapped. A panic in your handler is caught, logged, and the operation degrades in the direction that is safe:
| Where | What happens |
|---|---|
| An event handler | Caught, logged, this edit discarded |
| A packet interceptor | Caught, logged, the packet forwarded unchanged |
| An economy callback | Caught, logged, treated as no veto |
| A lane table function | Caught, logged, the fallback value returned |
| A scheduled task | Caught, logged, that one task dropped |
Note the direction. A panicking packet interceptor forwards rather than drops, because dropping everything would present as players being unable to join while the server looks fine, which is far harder to diagnose. A panicking economy callback does not veto, because a veto is the stronger action and should not be triggered by a bug.
This is a fence, not a feature. Handle your own errors.