-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use std::expected instead of throwing an exception , allows much better error handling in the tools. Still throw an exception when no other option (like during iterator) Also made the API for retrieving files case-insensitive. And upgrade the project to C++23 for std::expected
- Loading branch information
Showing
25 changed files
with
374 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) 2024 koolkdev | ||
* | ||
* This software may be modified and distributed under the terms | ||
* of the MIT license. See the LICENSE file for details. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <exception> | ||
#include <expected> | ||
|
||
enum WfsError { | ||
kItemNotFound, | ||
kNotDirectory, | ||
kNotFile, | ||
kBlockBadHash, | ||
kAreaHeaderCorrupted, | ||
kDirectoryCorrupted, | ||
kFreeBlocksAllocatorCorrupted, | ||
kFileDataCorrupted, | ||
kFileMetadataCorrupted, | ||
}; | ||
|
||
class WfsException : public std::exception { | ||
public: | ||
WfsException(WfsError error) : error_(error) {} | ||
virtual char const* what() const noexcept override; | ||
|
||
private: | ||
WfsError error_; | ||
}; | ||
|
||
template <typename T> | ||
T throw_if_error(std::expected<T, WfsError> res) { | ||
if (!res.has_value()) | ||
throw WfsException(res.error()); | ||
return *res; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.