-
Notifications
You must be signed in to change notification settings - Fork 9
refactor: Add error code in worker. #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sitaowang1998
wants to merge
21
commits into
y-scope:main
Choose a base branch
from
sitaowang1998:error_code
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
719e65b
Add depdency install through taskfile
sitaowang1998 a1a829c
Remove catch2 submodule
sitaowang1998 ed93185
Update cmake to use dependencies installed through tasks
sitaowang1998 c03700d
Add dep_install in lib_install to satisfy GH workflow
sitaowang1998 c7de69c
Add abseil in deps tasks
sitaowang1998 ad3a40a
Remove abseil from submodule and submodules directory
sitaowang1998 1d7d607
Rename abseil lib name
sitaowang1998 cff7ade
Update cmake for abseil installed by tasks
sitaowang1998 b94aff5
Add PIC in dependency
sitaowang1998 7995d1d
Add task to download ystdlib source
sitaowang1998 e02310c
Add ystdlib-cpp in cmake
sitaowang1998 1f6c808
Update clang format with ystdlib library
sitaowang1998 388b6c2
Add worker error code
sitaowang1998 e478ac5
[WIP] Update worker code to use error code. Not compiling
sitaowang1998 3652bf3
Merge branch 'main' into error_code
sitaowang1998 a01a1d3
Fix missing headers after merge
sitaowang1998 cff9eb3
Remove unused header include
sitaowang1998 fb00b88
Add temporary fix for quickcpplib
sitaowang1998 b30ed9a
Move constexpr into namespace
sitaowang1998 10d5f84
Improve todo comment for storage error code.
sitaowang1998 8f24a60
Merge branch 'main' into error_code
sitaowang1998 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,40 @@ | ||
| #include "WorkerErrorCode.hpp" | ||
|
|
||
| #include <string> | ||
| #include <string_view> | ||
|
|
||
| #include <ystdlib/error_handling/ErrorCode.hpp> | ||
|
|
||
| namespace spider::worker { | ||
| using WorkerErrorCategory = ystdlib::error_handling::ErrorCategory<WorkerErrorCodeEnum>; | ||
|
|
||
| constexpr std::string_view cWorkerErrorCategoryName = "Worker Error Code"; | ||
| } // namespace spider::worker | ||
|
|
||
| template <> | ||
| auto spider::worker::WorkerErrorCategory::name() const noexcept -> char const* { | ||
| return spider::worker::cWorkerErrorCategoryName.data(); | ||
| } | ||
|
|
||
| template <> | ||
| auto spider::worker::WorkerErrorCategory::message(spider::worker::WorkerErrorCodeEnum code) const | ||
| -> std::string { | ||
| switch (code) { | ||
| case spider::worker::WorkerErrorCodeEnum::Success: | ||
| return "Success"; | ||
| case spider::worker::WorkerErrorCodeEnum::CmdLineArgumentInvalid: | ||
| return "Invalid command line argument"; | ||
| case spider::worker::WorkerErrorCodeEnum::TaskArgumentInvalid: | ||
| return "Invalid task argument"; | ||
| case spider::worker::WorkerErrorCodeEnum::TaskFailed: | ||
| return "Task failed"; | ||
| case spider::worker::WorkerErrorCodeEnum::TaskOutputUnavailable: | ||
| return "Task output unavailable"; | ||
| case spider::worker::WorkerErrorCodeEnum::TaskOutputInvalid: | ||
| return "Task output invalid"; | ||
| case spider::worker::WorkerErrorCodeEnum::StorageError: | ||
| return "Storage error"; | ||
| default: | ||
| return "Unknown error"; | ||
| } | ||
| } |
This file contains hidden or 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,25 @@ | ||
| #ifndef SPIDER_WORKER_ERROR_CODE_HPP | ||
| #define SPIDER_WORKER_ERROR_CODE_HPP | ||
|
|
||
| #include <cstdint> | ||
|
|
||
| #include <ystdlib/error_handling/ErrorCode.hpp> | ||
|
|
||
| namespace spider::worker { | ||
| enum class WorkerErrorCodeEnum : uint8_t { | ||
| Success = 0, | ||
| CmdLineArgumentInvalid = 1, | ||
| TaskArgumentInvalid = 2, | ||
| TaskFailed = 3, | ||
| TaskOutputUnavailable = 4, | ||
| TaskOutputInvalid = 5, | ||
| // TODO: Move storage related errors to an ErrorCode in the storage namespace. | ||
| StorageError = 6, | ||
| }; | ||
|
|
||
| using WorkerErrorCode = ystdlib::error_handling::ErrorCode<WorkerErrorCodeEnum>; | ||
| } // namespace spider::worker | ||
|
|
||
| YSTDLIB_ERROR_HANDLING_MARK_AS_ERROR_CODE_ENUM(spider::worker::WorkerErrorCodeEnum); | ||
|
|
||
| #endif |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.