@@ -8,24 +8,37 @@ use thiserror::Error;
88// Rule of thumb: for public-facing functions or API use `TockloaderError`. For
99// crate-public/private functions you can use more specific errors.
1010
11+ /// Represents all possible errors that can occur within the Tockloader context.
1112#[ derive( Debug , Error ) ]
1213pub enum TockloaderError {
14+ /// Represents an error that can occur during serial communication. This
15+ /// does not include errors stemming from bad data or bad bootloader.
1316 #[ error( "Serial connection error: {0}" ) ]
1417 Serial ( #[ from] SerialError ) ,
1518
19+ /// Represents an error that can occur while interacting with a probe. This
20+ /// does not include errors stemming from bad data.
1621 #[ error( "Probe connection error: {0}" ) ]
1722 Probe ( #[ from] ProbeError ) ,
1823
24+ /// Represents an error that can occur while parsing a tab file.
1925 #[ error( "TAB file error: {0}" ) ]
2026 Tab ( #[ from] TabError ) ,
2127
28+ /// Represents an error that can occur while parsing Tock OS data or
29+ /// otherwise coming from a misconfigured of Tock OS.
2230 #[ error( "Tock OS error: {0}" ) ]
2331 Tock ( #[ from] TockError ) ,
2432
33+ /// Represents an error that occurs from internal violations of assumptions,
34+ /// or inconsistent state. It usually represents something that the user of
35+ /// this library did wrong.
2536 #[ error( "Internal tockloader error: {0}" ) ]
2637 Internal ( #[ from] InternalError ) ,
2738}
2839
40+ /// Represents errors that can occur during serial communication. This does not
41+ /// include errors stemming from bad data or bad bootloader.
2942#[ derive( Debug , Error ) ]
3043pub enum SerialError {
3144 #[ error( "Failed to interface in serial using tokio_serial: {0}" ) ]
@@ -35,6 +48,8 @@ pub enum SerialError {
3548 IO ( #[ from] io:: Error ) ,
3649}
3750
51+ /// Represents errors that can occur while interacting with a probe. This does
52+ /// not include errors stemming from bad data.
3853#[ derive( Debug , Error ) ]
3954pub enum ProbeError {
4055 #[ error( "Failed to interact with probe: {0}" ) ]
@@ -47,6 +62,7 @@ pub enum ProbeError {
4762 Flashing ( #[ from] probe_rs:: flashing:: FlashError ) ,
4863}
4964
65+ /// Represents errors that can occur while parsing a tab file.
5066#[ derive( Debug , Error ) ]
5167pub enum TabError {
5268 #[ error( "Failed to use tab due to IO error: {0}" ) ]
@@ -65,6 +81,8 @@ pub enum TabError {
6581 MissingBinary ( String ) ,
6682}
6783
84+ /// Represents errors that can occur while parsing Tock OS data or otherwise
85+ /// coming from a misconfigured of Tock OS.
6886#[ derive( Debug , Error ) ]
6987pub enum TockError {
7088 #[ error( "Bootloader returned an invalid header: {0} {1}" ) ]
@@ -83,6 +101,7 @@ pub enum TockError {
83101 MissingAttribute ( String ) ,
84102}
85103
104+ /// Represents errors that can occur while parsing attributes.
86105#[ derive( Debug , Error ) ]
87106pub enum AttributeParseError {
88107 #[ error( "Expected attribute to be a valid number. Inner: {0}" ) ]
@@ -92,6 +111,8 @@ pub enum AttributeParseError {
92111 InvalidString ( #[ from] std:: string:: FromUtf8Error ) ,
93112}
94113
114+ /// Represents internal violations of assumptions, or inconsistent state. It
115+ /// usually represents something that the user of this library did wrong.
95116#[ derive( Debug , Error ) ]
96117pub enum InternalError {
97118 #[ error( "Operation failed due to board not being open." ) ]
0 commit comments