Skip to main content

nibkeep_log/
error.rs

1//! Why changes are rejected.
2
3use nibkeep_base::cbor;
4use nibkeep_time::ClockError;
5
6/// Why a change could not be made or was rejected.
7#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)]
8#[non_exhaustive]
9pub enum LogError {
10	/// The change belongs to another space.
11	#[error("the change belongs to another space")]
12	OtherSpace,
13	/// The change's signature is not valid for its author.
14	#[error("the change's signature is not valid")]
15	InvalidSignature,
16	/// The change's key is wrapped with a space key that this replica does not have.
17	#[error(
18		"the change's key is wrapped with key {0} of the space, which this device does not have"
19	)]
20	UnknownEpoch(u64),
21	/// The change's payload does not open with the change's key.
22	#[error("the change's operations cannot be decrypted")]
23	Decryption,
24	/// The change's payload does not have the form of a payload, or does not seal the
25	/// statements that the change's header names.
26	#[error("the change's operations cannot be read: {0}")]
27	Operations(cbor::Error),
28	/// The sealed payload is not the one whose hash the change's header holds.
29	#[error("the payload is not the change's")]
30	OtherPayload,
31	/// The wrapped key does not open to the key whose hash the change's header holds.
32	#[error("the wrapped key is not the change's")]
33	OtherKey,
34	/// The replica does not have the change that a payload or key belongs to.
35	#[error("this device does not have the change")]
36	UnknownChange,
37	/// A change that sets the keys of replicas would hold something else too.
38	#[error("a change that sets the keys of devices holds nothing else")]
39	MixedGoverning,
40	/// A change that governs the space is wrapped with another key than the space's first,
41	/// which every replica holds, so that some replicas could not read it.
42	#[error("a change that sets the keys of devices is wrapped with another key than the first")]
43	GoverningEpoch,
44	/// The change is not later than one of its parents.
45	#[error("the change is not later than its parents")]
46	NotAfterParents,
47	/// One of the change's parents, or one of their ancestors, was rejected.
48	#[error("one of the change's parents was rejected")]
49	RejectedParent,
50	/// A change without parents that is not the space's first change, which the replica
51	/// was told.
52	#[error("the change is not the space's first change")]
53	UnexpectedRoot,
54	/// A change without parents, in a space whose first change governs it and that has one
55	/// already.
56	#[error("the space has a first change already")]
57	SecondRoot,
58	/// A change without parents that does not govern the space, in a space whose first change
59	/// must govern it.
60	#[error("the space's first change must say who may write to it")]
61	UngovernedRoot,
62	/// No governing change of the space lists the key that signed the change, in a space
63	/// whose first change governs it. The change is not kept, until such a listing arrives.
64	#[error("no device of the space has the key that signed the change")]
65	UnknownAuthor,
66	/// Too many changes are already waiting for their parents.
67	#[error("too many changes are waiting for their parents")]
68	TooManyWaiting,
69	/// Writing or purging a secret value needs the space's secrets key, or the opened
70	/// value.
71	#[error("secret values need the space's secrets key")]
72	SecretsLocked,
73	/// A statement is not one that this replica can purge: it does not have it, or it was
74	/// asserted in a change that governs the space, or whose payload it cannot read.
75	#[error("the value cannot be purged here")]
76	CannotPurge,
77	/// This replica has no key for the blob to purge.
78	#[error("this device has no key for the blob")]
79	UnknownBlob,
80	/// The change purges or restores a change that it does not build on, or one that governs
81	/// the space, or a statement that is not sealed in a change it builds on; or it restores
82	/// and purges at once.
83	#[error("the change purges or restores what it does not build on, or what governs the space")]
84	InvalidPurge,
85	/// A change that restores what purges destroyed would not count: its author's role does
86	/// not allow purging what it restores.
87	#[error("this replica's role does not allow restoring what the purge destroyed")]
88	CannotRestore,
89	/// The storage of the state could not be read or written, so the log no longer matches
90	/// it and must be built again. [`Log::storage_error`](crate::Log::storage_error) says why.
91	#[error("the state could not be read or written; the log must be built again")]
92	Storage,
93	/// A page of a replica's account of what it holds does not read
94	/// ([`AccountPage`](crate::AccountPage)).
95	#[error("an account of copies does not read: {0}")]
96	Account(&'static str),
97	/// The change's timestamp is too far ahead of the wall clock, or the clock has run out
98	/// of timestamps.
99	#[error(transparent)]
100	Clock(#[from] ClockError),
101}