ghast_ext/error.rs
1//! The error type of the helpers.
2
3use ghast_client::BlockPos;
4use ghast_client::inventory::ClickError;
5
6/// Why a helper gave up. Nothing was left half-done: buttons are released and a window the
7/// helper opened is closed again.
8#[derive(Debug, Clone, PartialEq, thiserror::Error)]
9#[non_exhaustive]
10pub enum Error {
11 /// The session ended (or the handle belongs to a session that ended).
12 #[error("the session ended")]
13 Disconnected,
14 /// The helper did not finish within its time limit.
15 #[error("timed out")]
16 Timeout,
17 /// The server teleported / set back the player while the helper was running.
18 #[error("teleported by the server")]
19 Teleported,
20 /// The player died while the helper was running.
21 #[error("the player died")]
22 Died,
23 /// The block's chunk column is not loaded (never treated as air).
24 #[error("block {0:?} is not loaded")]
25 NotLoaded(BlockPos),
26 /// There is nothing to dig (air).
27 #[error("nothing to dig at {0:?}")]
28 NothingToDig(BlockPos),
29 /// The block cannot be broken (bedrock, barriers, ...).
30 #[error("block {0:?} cannot be broken")]
31 Unbreakable(BlockPos),
32 /// No face of the block can be reached with an unobstructed crosshair (reach 4.5).
33 #[error("block {0:?} is out of reach or hidden")]
34 OutOfReach(BlockPos),
35 /// The crosshair left the block while digging (something moved in between).
36 #[error("lost the crosshair on {0:?}")]
37 LostTarget(BlockPos),
38 /// The block to place into is occupied (not air or a liquid), or the player stands in it.
39 #[error("{0:?} is occupied")]
40 Occupied(BlockPos),
41 /// The block to place against is air.
42 #[error("nothing to place against at {0:?}")]
43 NoSupport(BlockPos),
44 /// The block placed against reacts to a right click (chest, door, ...): placing would
45 /// activate it. Sneak first (`set_controls` with `sneak`) or pick another face.
46 #[error("block {0:?} would be activated instead")]
47 WouldActivate(BlockPos),
48 /// The server did not put a block there (it refused the placement).
49 #[error("no block appeared at {0:?}")]
50 NotPlaced(BlockPos),
51 /// Nothing in the hand.
52 #[error("nothing held")]
53 NothingHeld,
54 /// No stack matches.
55 #[error("no matching item: {0}")]
56 NoSuchItem(String),
57 /// An item name this version does not know.
58 #[error("unknown item name {0:?}")]
59 UnknownItem(String),
60 /// A block name this version does not know.
61 #[error("unknown block name {0:?}")]
62 UnknownBlock(String),
63 /// The helper needs an open container window.
64 #[error("no container window is open")]
65 NoWindow,
66 /// The inventory refused the click for good (not a retryable refusal).
67 #[error("click refused: {0}")]
68 Click(ClickError),
69 /// The server rejected the click (the inventory resyncs).
70 #[error("the server rejected the click")]
71 ClickRejected,
72 /// No confirm arrived for the click.
73 #[error("the click was not confirmed")]
74 ClickTimedOut,
75 /// The held item cannot be used now (not usable, full food bar, ...).
76 #[error("the held item cannot be used now")]
77 CannotUse,
78 /// The task was aborted or its session ended before it finished.
79 #[error("the task was cancelled")]
80 Cancelled,
81 /// The task panicked.
82 #[error("the task panicked: {0}")]
83 Panicked(String),
84 /// The entity is not tracked (gone, or [`ghast_client::Interests::ENTITIES`] is off).
85 #[error("entity {0} is not tracked")]
86 NoSuchEntity(i32),
87 /// No path to the goal.
88 #[error("no path to the goal")]
89 NoPath,
90 /// The walker made no progress.
91 #[error("stuck")]
92 Stuck,
93}