|
1 | 1 | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
2 | 2 | // SPDX-License-Identifier: Apache-2.0
|
3 |
| - |
4 |
| -use std::fmt::{Display, Formatter, Result}; |
5 | 3 | use std::net::Ipv4Addr;
|
6 | 4 |
|
7 | 5 | use mmds::data_store;
|
@@ -40,46 +38,22 @@ impl MmdsConfig {
|
40 | 38 | }
|
41 | 39 |
|
42 | 40 | /// MMDS configuration related errors.
|
43 |
| -#[derive(Debug)] |
| 41 | +#[derive(Debug, thiserror::Error)] |
44 | 42 | pub enum MmdsConfigError {
|
45 | 43 | /// The network interfaces list provided is empty.
|
| 44 | + #[error("The list of network interface IDs that allow forwarding MMDS requests is empty.")] |
46 | 45 | EmptyNetworkIfaceList,
|
47 | 46 | /// The provided IPv4 address is not link-local valid.
|
| 47 | + #[error("The MMDS IPv4 address is not link local.")] |
48 | 48 | InvalidIpv4Addr,
|
49 | 49 | /// The network interfaces list provided contains IDs that
|
50 | 50 | /// does not correspond to any existing network interface.
|
| 51 | + #[error( |
| 52 | + "The list of network interface IDs provided contains at least one ID that does not \ |
| 53 | + correspond to any existing network interface." |
| 54 | + )] |
51 | 55 | InvalidNetworkInterfaceId,
|
52 | 56 | /// MMDS version could not be configured.
|
| 57 | + #[error("The MMDS could not be configured to version {0}: {1}")] |
53 | 58 | MmdsVersion(MmdsVersion, data_store::Error),
|
54 | 59 | }
|
55 |
| - |
56 |
| -impl Display for MmdsConfigError { |
57 |
| - fn fmt(&self, f: &mut Formatter<'_>) -> Result { |
58 |
| - match self { |
59 |
| - MmdsConfigError::EmptyNetworkIfaceList => { |
60 |
| - write!( |
61 |
| - f, |
62 |
| - "The list of network interface IDs that allow forwarding MMDS requests is \ |
63 |
| - empty." |
64 |
| - ) |
65 |
| - } |
66 |
| - MmdsConfigError::InvalidIpv4Addr => { |
67 |
| - write!(f, "The MMDS IPv4 address is not link local.") |
68 |
| - } |
69 |
| - MmdsConfigError::InvalidNetworkInterfaceId => { |
70 |
| - write!( |
71 |
| - f, |
72 |
| - "The list of network interface IDs provided contains at least one ID that \ |
73 |
| - does not correspond to any existing network interface." |
74 |
| - ) |
75 |
| - } |
76 |
| - MmdsConfigError::MmdsVersion(version, err) => { |
77 |
| - write!( |
78 |
| - f, |
79 |
| - "The MMDS could not be configured to version {}: {}", |
80 |
| - version, err |
81 |
| - ) |
82 |
| - } |
83 |
| - } |
84 |
| - } |
85 |
| -} |
0 commit comments