Advanced
Errors and Recovery
Handle runtime failures with typed errors and recovery strategies.
This guide covers practical error handling based on exported error classes. It focuses on predictable fallbacks, typed guards and recovery-safe command flow.
Type reference: Core API (TypeDoc)
Quick links:
Typed Error Handling
import {
,
,
,
,
,
,
,
} from 'hoshimi';
try {
// any operation that may fail
} catch () {
if ( instanceof ) {
.('Invalid options:', .);
} else if ( instanceof ) {
.('Manager state error:', .);
} else if ( instanceof ) {
.('Node connection error:', .);
} else if ( instanceof ) {
.('Playback error:', .);
} else if ( instanceof ) {
.('Track resolve error:', .);
} else if ( instanceof ) {
.('Lavalink REST error:', .);
} else if ( instanceof ) {
.('Storage adapter error:', .);
}
}Recovery Checklist
- Before commands: check manager health (
isUseable). - Before player operations: verify voice channel and player existence.
- For queue operations: guard with
queue.isEmpty(). - On reconnect-sensitive flows: persist player/session data after updates.
- On teardown (
QueueEnd/PlayerDestroy): clear transient storage (lyrics/message IDs).