Skip to content

Commit dc393b3

Browse files
authored
Merge pull request #162 from RobLoach/exception
Add Exceptions
2 parents e318c61 + 8e5d204 commit dc393b3

File tree

156 files changed

+5163
-3383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+5163
-3383
lines changed

.github/workflows/Tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ jobs:
2222
run: cmake --build build
2323

2424
- name: Test
25-
run: ./build/tests/raylib_test
25+
run: ./build/tests/raylib_cpp_test

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,26 @@ std::string url = "https://raylib.com";
220220
raylib::OpenURL(url);
221221
```
222222
223+
### Exceptions
224+
225+
When loading an asset fails, raylib will log a warning, but provide no other feedback for you to act upon. raylib-cpp will throw a [`RaylibException`](include/RaylibException.hpp) [runtime exception](https://en.cppreference.com/w/cpp/error/runtime_error), allowing to provide a safe method to catch failed loads.
226+
227+
``` cpp
228+
// raylib
229+
Texture texture = LoadTexture("FileNotFound.png");
230+
if (texture.width == 0) {
231+
TraceLog(LOG_ERROR, "Texture failed to load!");
232+
}
233+
234+
// raylib-cpp
235+
try {
236+
raylib::Texture texture("FileNotFound.png");
237+
}
238+
catch (raylib::RaylibException& error) {
239+
error.TraceLog(LOG_ERROR);
240+
}
241+
```
242+
223243
### RayMath
224244

225245
The [raymath](https://github.com/raysan5/raylib/blob/master/src/raymath.h) methods are included.

clib.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"include/Physics.hpp",
4444
"include/Ray.hpp",
4545
"include/RayCollision.hpp",
46+
"include/RaylibException.hpp",
4647
"include/raylib-cpp-utils.hpp",
4748
"include/raylib-cpp.hpp",
4849
"include/raylib.hpp",

docs/_audio_device_8hpp_source.html

Lines changed: 47 additions & 43 deletions
Large diffs are not rendered by default.

docs/_audio_stream_8hpp_source.html

Lines changed: 148 additions & 126 deletions
Large diffs are not rendered by default.

docs/_bounding_box_8hpp_source.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160; </div>
131131
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160;<span class="preprocessor">#endif // RAYLIB_CPP_INCLUDE_BOUNDINGBOX_HPP_</span></div>
132132
</div><!-- fragment --></div><!-- contents -->
133-
<div class="ttc" id="anamespaceraylib_html"><div class="ttname"><a href="namespaceraylib.html">raylib</a></div><div class="ttdoc">All raylib-cpp classes and functions appear in the raylib namespace.</div><div class="ttdef"><b>Definition:</b> <a href="_audio_device_8hpp_source.html#l00007">AudioDevice.hpp:7</a></div></div>
133+
<div class="ttc" id="anamespaceraylib_html"><div class="ttname"><a href="namespaceraylib.html">raylib</a></div><div class="ttdoc">All raylib-cpp classes and functions appear in the raylib namespace.</div><div class="ttdef"><b>Definition:</b> <a href="_audio_device_8hpp_source.html#l00008">AudioDevice.hpp:8</a></div></div>
134134
<div class="ttc" id="aclassraylib_1_1_ray_collision_html"><div class="ttname"><a href="classraylib_1_1_ray_collision.html">raylib::RayCollision</a></div><div class="ttdoc">Raycast hit information.</div><div class="ttdef"><b>Definition:</b> <a href="_ray_collision_8hpp_source.html#l00011">RayCollision.hpp:11</a></div></div>
135135
<div class="ttc" id="aclassraylib_1_1_bounding_box_html_a8417253000c9381b4afc1869d5e3a611"><div class="ttname"><a href="classraylib_1_1_bounding_box.html#a8417253000c9381b4afc1869d5e3a611">raylib::BoundingBox::BoundingBox</a></div><div class="ttdeci">BoundingBox(const ::Mesh &amp;mesh)</div><div class="ttdoc">Compute mesh bounding box limits.</div><div class="ttdef"><b>Definition:</b> <a href="_bounding_box_8hpp_source.html#l00020">BoundingBox.hpp:20</a></div></div>
136136
<div class="ttc" id="aclassraylib_1_1_bounding_box_html_aae0a66351992f36372ef68a6d4508c62"><div class="ttname"><a href="classraylib_1_1_bounding_box.html#aae0a66351992f36372ef68a6d4508c62">raylib::BoundingBox::Draw</a></div><div class="ttdeci">BoundingBox &amp; Draw(::Color color={255, 255, 255, 255})</div><div class="ttdoc">Draw a bounding box with wires.</div><div class="ttdef"><b>Definition:</b> <a href="_bounding_box_8hpp_source.html#l00038">BoundingBox.hpp:38</a></div></div>

docs/_camera2_d_8hpp_source.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; </div>
134134
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>&#160;<span class="preprocessor">#endif // RAYLIB_CPP_INCLUDE_CAMERA2D_HPP_</span></div>
135135
</div><!-- fragment --></div><!-- contents -->
136-
<div class="ttc" id="anamespaceraylib_html"><div class="ttname"><a href="namespaceraylib.html">raylib</a></div><div class="ttdoc">All raylib-cpp classes and functions appear in the raylib namespace.</div><div class="ttdef"><b>Definition:</b> <a href="_audio_device_8hpp_source.html#l00007">AudioDevice.hpp:7</a></div></div>
136+
<div class="ttc" id="anamespaceraylib_html"><div class="ttname"><a href="namespaceraylib.html">raylib</a></div><div class="ttdoc">All raylib-cpp classes and functions appear in the raylib namespace.</div><div class="ttdef"><b>Definition:</b> <a href="_audio_device_8hpp_source.html#l00008">AudioDevice.hpp:8</a></div></div>
137137
<div class="ttc" id="aclassraylib_1_1_matrix_html"><div class="ttname"><a href="classraylib_1_1_matrix.html">raylib::Matrix</a></div><div class="ttdoc">Matrix type (OpenGL style 4x4 - right handed, column major)</div><div class="ttdef"><b>Definition:</b> <a href="_matrix_8hpp_source.html#l00016">Matrix.hpp:16</a></div></div>
138138
<div class="ttc" id="aclassraylib_1_1_camera2_d_html_a1eed5bde73d8c1a227250b6caaefcb42"><div class="ttname"><a href="classraylib_1_1_camera2_d.html#a1eed5bde73d8c1a227250b6caaefcb42">raylib::Camera2D::GetScreenToWorld</a></div><div class="ttdeci">Vector2 GetScreenToWorld(::Vector2 position) const</div><div class="ttdoc">Returns the world space position for a 2d camera screen space position.</div><div class="ttdef"><b>Definition:</b> <a href="_camera2_d_8hpp_source.html#l00059">Camera2D.hpp:59</a></div></div>
139139
<div class="ttc" id="aclassraylib_1_1_camera2_d_html_aa1f8ea4d3a25feb15c2cb2a09628c7a1"><div class="ttname"><a href="classraylib_1_1_camera2_d.html#aa1f8ea4d3a25feb15c2cb2a09628c7a1">raylib::Camera2D::GetMatrix</a></div><div class="ttdeci">Matrix GetMatrix() const</div><div class="ttdoc">Returns camera 2d transform matrix.</div><div class="ttdef"><b>Definition:</b> <a href="_camera2_d_8hpp_source.html#l00045">Camera2D.hpp:45</a></div></div>

docs/_camera3_d_8hpp_source.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span>&#160; </div>
189189
<div class="line"><a name="l00164"></a><span class="lineno"> 164</span>&#160;<span class="preprocessor">#endif // RAYLIB_CPP_INCLUDE_CAMERA3D_HPP_</span></div>
190190
</div><!-- fragment --></div><!-- contents -->
191-
<div class="ttc" id="anamespaceraylib_html"><div class="ttname"><a href="namespaceraylib.html">raylib</a></div><div class="ttdoc">All raylib-cpp classes and functions appear in the raylib namespace.</div><div class="ttdef"><b>Definition:</b> <a href="_audio_device_8hpp_source.html#l00007">AudioDevice.hpp:7</a></div></div>
191+
<div class="ttc" id="anamespaceraylib_html"><div class="ttname"><a href="namespaceraylib.html">raylib</a></div><div class="ttdoc">All raylib-cpp classes and functions appear in the raylib namespace.</div><div class="ttdef"><b>Definition:</b> <a href="_audio_device_8hpp_source.html#l00008">AudioDevice.hpp:8</a></div></div>
192192
<div class="ttc" id="aclassraylib_1_1_matrix_html"><div class="ttname"><a href="classraylib_1_1_matrix.html">raylib::Matrix</a></div><div class="ttdoc">Matrix type (OpenGL style 4x4 - right handed, column major)</div><div class="ttdef"><b>Definition:</b> <a href="_matrix_8hpp_source.html#l00016">Matrix.hpp:16</a></div></div>
193193
<div class="ttc" id="anamespaceraylib_html_abd45302dac72cb253026bce044dee236"><div class="ttname"><a href="namespaceraylib.html#abd45302dac72cb253026bce044dee236">raylib::UpdateCamera</a></div><div class="ttdeci">static void UpdateCamera(const ::Camera &amp;camera)</div><div class="ttdoc">Update camera depending on selected mode.</div><div class="ttdef"><b>Definition:</b> <a href="_functions_8hpp_source.html#l00195">Functions.hpp:195</a></div></div>
194194
<div class="ttc" id="aclassraylib_1_1_camera3_d_html_ac59decb87b851c16adee7c2c742f8961"><div class="ttname"><a href="classraylib_1_1_camera3_d.html#ac59decb87b851c16adee7c2c742f8961">raylib::Camera3D::GetMouseRay</a></div><div class="ttdeci">Ray GetMouseRay(::Vector2 mousePosition) const</div><div class="ttdoc">Returns a ray trace from mouse position.</div><div class="ttdef"><b>Definition:</b> <a href="_camera3_d_8hpp_source.html#l00115">Camera3D.hpp:115</a></div></div>

docs/_color_8hpp_source.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
<div class="line"><a name="l00257"></a><span class="lineno"> 257</span>&#160; </div>
283283
<div class="line"><a name="l00258"></a><span class="lineno"> 258</span>&#160;<span class="preprocessor">#endif // RAYLIB_CPP_INCLUDE_COLOR_HPP_</span></div>
284284
</div><!-- fragment --></div><!-- contents -->
285-
<div class="ttc" id="anamespaceraylib_html"><div class="ttname"><a href="namespaceraylib.html">raylib</a></div><div class="ttdoc">All raylib-cpp classes and functions appear in the raylib namespace.</div><div class="ttdef"><b>Definition:</b> <a href="_audio_device_8hpp_source.html#l00007">AudioDevice.hpp:7</a></div></div>
285+
<div class="ttc" id="anamespaceraylib_html"><div class="ttname"><a href="namespaceraylib.html">raylib</a></div><div class="ttdoc">All raylib-cpp classes and functions appear in the raylib namespace.</div><div class="ttdef"><b>Definition:</b> <a href="_audio_device_8hpp_source.html#l00008">AudioDevice.hpp:8</a></div></div>
286286
<div class="ttc" id="aclassraylib_1_1_vector4_html"><div class="ttname"><a href="classraylib_1_1_vector4.html">raylib::Vector4</a></div><div class="ttdoc">Vector4 type.</div><div class="ttdef"><b>Definition:</b> <a href="_vector4_8hpp_source.html#l00017">Vector4.hpp:17</a></div></div>
287287
<div class="ttc" id="aclassraylib_1_1_color_html_ace467f20d71ff4af44e0211d6aeea9b5"><div class="ttname"><a href="classraylib_1_1_color.html#ace467f20d71ff4af44e0211d6aeea9b5">raylib::Color::ClearBackground</a></div><div class="ttdeci">Color &amp; ClearBackground()</div><div class="ttdoc">Set background color (framebuffer clear color)</div><div class="ttdef"><b>Definition:</b> <a href="_color_8hpp_source.html#l00107">Color.hpp:107</a></div></div>
288288
<div class="ttc" id="aclassraylib_1_1_color_html_ae94a7282beb9cd71dd8d1b0dac24652a"><div class="ttname"><a href="classraylib_1_1_color.html#ae94a7282beb9cd71dd8d1b0dac24652a">raylib::Color::Color</a></div><div class="ttdeci">Color(unsigned int hexValue)</div><div class="ttdoc">Get Color structure from hexadecimal value.</div><div class="ttdef"><b>Definition:</b> <a href="_color_8hpp_source.html#l00048">Color.hpp:48</a></div></div>

0 commit comments

Comments
 (0)