Libraries/DiskStorage/src/include/Storage/Disk/Error.h
Go to the documentation of this file.
1 /****
2  * Error.h
3  *
4  * Copyright 2022 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the DiskStorage Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  ****/
19 
20 #pragma once
21 
22 #include <WString.h>
23 
24 namespace Storage::Disk
25 {
26 #define DISK_ERRORCODE_MAP(XX) \
27  XX(Success, "Success") \
28  XX(BadParam, "Invalid parameter(s)") \
29  XX(MisAligned, "Partition is mis-aligned") \
30  XX(OutOfRange, "Partition offset out of valid range") \
31  XX(NoSpace, "No room for partition(s)") \
32  XX(NoMem, "Memory allocation failed") \
33  XX(ReadFailure, "Media read failed") \
34  XX(WriteFailure, "Media write failed") \
35  XX(EraseFailure, "Media erase failed")
36 
37 enum class Error {
38 #define XX(tag, ...) tag,
40 #undef XX
41 };
42 
43 inline bool operator!(Error err)
44 {
45  return err == Error::Success;
46 }
47 
48 } // namespace Storage::Disk
49 
String toString(Storage::Disk::Error err)
#define DISK_ERRORCODE_MAP(XX)
Definition: Libraries/DiskStorage/src/include/Storage/Disk/Error.h:26
The String class.
Definition: WString.h:137
Definition: Partition.h:78
bool operator!(Error err)
Definition: Libraries/DiskStorage/src/include/Storage/Disk/Error.h:43
Error
Definition: Libraries/DiskStorage/src/include/Storage/Disk/Error.h:37