Skip to content

Commit e09ae61

Browse files
authored
chore: merge pull request #4 from threeal/add-error-package
Add Error Package
2 parents f167954 + 60d120c commit e09ae61

File tree

17 files changed

+121
-70
lines changed

17 files changed

+121
-70
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ jobs:
1414
- name: Configure and build this project
1515
uses: threeal/cmake-action@v1.1.0
1616
with:
17-
source-dir: example
18-
build-dir: example/build
17+
source-dir: error
18+
build-dir: error/build

.github/workflows/test.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ jobs:
1414
- name: Configure, build, and test this project
1515
uses: threeal/cmake-action@v1.1.0
1616
with:
17-
source-dir: example
18-
build-dir: example/build
17+
source-dir: error
18+
build-dir: error/build
1919
args: -DBUILD_TESTING=ON
2020
run-test: true
2121

2222
- name: Check code coverage
2323
uses: threeal/gcovr-action@main
2424
with:
25-
root: example
25+
root: error
2626
excludes: |
27-
example/build/*
28-
example/test/*
27+
error/build/*
28+
error/test/*
2929
fail-under-line: 100
3030

3131
check-warning:
@@ -37,8 +37,8 @@ jobs:
3737
- name: Configure and build this project
3838
uses: threeal/cmake-action@v1.1.0
3939
with:
40-
source-dir: example
41-
build-dir: example/build
40+
source-dir: error
41+
build-dir: error/build
4242
cxx-flags: -Werror
4343
args: -DBUILD_TESTING=ON
4444

@@ -52,9 +52,9 @@ jobs:
5252
run: pip3 install cmake-format
5353

5454
- name: Configure CMake
55-
run: cmake example -B example/build
55+
run: cmake error -B error/build
5656

5757
- name: Check code formatting
5858
run: |
59-
cmake --build example/build --target format
60-
cmake --build example/build --target check-format
59+
cmake --build error/build --target format
60+
cmake --build error/build --target check-format

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
A comprehensive collection of [C++](https://isocpp.org/) utility packages.
77

8+
## Packages
9+
10+
- [Error](./error) [WIP]: Provides utilities for error handling.
11+
812
## License
913

1014
This project is licensed under the terms of the [MIT License](./LICENSE).
File renamed without changes.
File renamed without changes.
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
cmake_minimum_required(VERSION 3.0)
22

3-
project(example)
3+
project(error)
44

5-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wpedantic")
5+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -Wpedantic")
6+
set(CMAKE_CXX_STANDARD 11)
67

7-
add_library(example src/example.cpp)
8-
target_include_directories(example PUBLIC include)
8+
add_library(error src/error.cpp)
9+
target_include_directories(error PUBLIC include)
910

1011
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
1112
include(cmake/CPM.cmake)
@@ -19,8 +20,8 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
1920

2021
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -fPIC -O0")
2122

22-
add_executable(example_test test/example_test.cpp)
23-
target_link_libraries(example_test PRIVATE example Catch2::Catch2WithMain)
24-
catch_discover_tests(example_test)
23+
add_executable(error_test test/error_test.cpp)
24+
target_link_libraries(error_test PRIVATE error Catch2::Catch2WithMain)
25+
catch_discover_tests(error_test)
2526
endif()
2627
endif()

error/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Alfi Maulana
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

error/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Error
2+
3+
A C++ package that provides utilities for error handling.
4+
5+
## License
6+
7+
This project is licensed under the terms of the [MIT License](./LICENSE).
8+
9+
Copyright © 2023 [Alfi Maulana](https://github.com/threeal)
File renamed without changes.

error/include/error/error.hpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#pragma once
2+
3+
#include <exception>
4+
5+
namespace error {
6+
7+
/**
8+
* @brief A class that represents error information.
9+
*/
10+
class Error : public std::exception {
11+
private:
12+
const char* message; /**< The error message. */
13+
14+
public:
15+
/**
16+
* @brief Constructs a new error with the given message.
17+
* @param message An error message.
18+
*/
19+
Error(const char* message);
20+
21+
/**
22+
* @brief Returns the explanatory string.
23+
* @return Pointer to a null-terminated string with explanatory information.
24+
*/
25+
const char* what() const noexcept override;
26+
};
27+
28+
} // namespace error

0 commit comments

Comments
 (0)