Skip to content
Edit this page View source of this page

Error Handling

RustyCord methods that call Discord return:

Result<T, Box<dyn std::error::Error + Send + Sync>>

This lets ? work cleanly in handlers and application code. HTTP 429 responses are represented internally by a structured RateLimitError after the automatic retry budget is exhausted.

```rust,no_run match client .send_text_message(channel_id, "Deployment complete") .await { Ok(message) => println!("Sent message {}", message.id), Err(error) => { log::error!("Discord request failed: {}", error); } }

## Common failures

- **Invalid token:** verify `DISCORD_TOKEN` before starting the bot.
- **Missing permissions:** ensure the bot role has the required channel and guild permissions.
- **Missing intents:** enable privileged intents in the Discord Developer Portal and request them on the gateway.
- **Rate limited:** RustyCord waits on `X-RateLimit-*` and `Retry-After` headers automatically before raising the error.

## Build-time checks

Run the following before submitting changes:

```bash
cargo fmt --all -- --check
cargo check --all-features --all-targets
cargo test --all-features --all-targets
cargo clippy --all-features --all-targets -- -D warnings
zensical build --strict

These commands verify formatting, compilation, unit behavior, lint posture, and documentation links.