Skip to content

Commit

Permalink
Use BOOST_THROW_EXCEPTION more (#3447)
Browse files Browse the repository at this point in the history
  • Loading branch information
RAOF authored Jun 27, 2024
2 parents b526b15 + b4dbd84 commit 688d231
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/common/sharedlibrary/shared_library_prober.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "mir/shared_library.h"

#include <boost/filesystem.hpp>
#include <boost/throw_exception.hpp>

#include <system_error>
#include <cstring>
Expand All @@ -31,8 +32,8 @@ std::error_code boost_to_std_error(boost::system::error_code const& ec)
{
if (ec.category() != boost::system::system_category())
{
throw std::logic_error{"Boost error from unexpected category: " +
ec.message()};
BOOST_THROW_EXCEPTION(std::logic_error{"Boost error from unexpected category: " +
ec.message()});
}
return std::error_code{ec.value(), std::system_category()};
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/depth_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "mir/depth_layer.h"

#ifndef __clang__
#include <stdexcept>
#include "mir/fatal.h"
#endif

auto mir::mir_depth_layer_get_index(MirDepthLayer depth_layer) -> unsigned int
Expand All @@ -34,6 +34,6 @@ auto mir::mir_depth_layer_get_index(MirDepthLayer depth_layer) -> unsigned int
// GCC and Clang both ensure the switch is exhaustive.
// GCC, however, gets a "control reaches end of non-void function" warning without this
#ifndef __clang__
throw std::logic_error("Invalid MirDepthLayer in mir::mir_depth_layer_get_index()");
fatal_error_abort("Invalid MirDepthLayer in mir::mir_depth_layer_get_index()");
#endif
}
6 changes: 3 additions & 3 deletions src/miral/basic_window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1121,20 +1121,20 @@ void miral::BasicWindowManager::modify_window(WindowInfo& window_info, WindowSpe

if (!window_info.can_morph_to(new_type))
{
throw std::runtime_error("Unsupported window type change");
BOOST_THROW_EXCEPTION(std::runtime_error("Unsupported window type change"));
}

if (window_info_tmp.must_not_have_parent())
{
if (modifications.parent().is_set())
throw std::runtime_error("Target window type does not support parent");
BOOST_THROW_EXCEPTION(std::runtime_error("Target window type does not support parent"));

window_info_tmp.parent({});
}
else if (window_info_tmp.must_have_parent())
{
if (!window_info_tmp.parent())
throw std::runtime_error("Target window type requires parent");
BOOST_THROW_EXCEPTION(std::runtime_error("Target window type requires parent"));
}
}

Expand Down
1 change: 0 additions & 1 deletion src/platforms/eglstream-kms/server/buffer_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
#include <boost/throw_exception.hpp>
#include <boost/exception/errinfo_errno.hpp>

#include <system_error>
#include <cassert>


Expand Down
1 change: 0 additions & 1 deletion src/platforms/gbm-kms/server/buffer_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@

#include <optional>
#include <stdexcept>
#include <system_error>
#include <cassert>
#include <fcntl.h>
#include <xf86drm.h>
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/gbm-kms/server/kms/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ mgg::Cursor::Cursor(

hide();
if (last_set_failed)
throw std::runtime_error("Initial KMS cursor set failed");
BOOST_THROW_EXCEPTION(std::runtime_error("Initial KMS cursor set failed"));
}

mgg::Cursor::~Cursor() noexcept
Expand Down
4 changes: 2 additions & 2 deletions src/platforms/gbm-kms/server/kms/platform_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@ auto probe_display_platform(

if (auto error = -drmSetInterfaceVersion(tmp_fd, &sv))
{
throw std::system_error{
BOOST_THROW_EXCEPTION((std::system_error{
error,
std::system_category(),
std::string{"Failed to set DRM interface version on device "} + device.devnode()};
std::string{"Failed to set DRM interface version on device "} + device.devnode()}));
}

// For now, we *also* require our DisplayPlatform to support creating a HW EGL context
Expand Down
2 changes: 1 addition & 1 deletion src/server/graphics/default_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ auto mir::DefaultServerConfiguration::the_rendering_platforms() ->
if (platforms.empty())
{
auto msg = "Failed to find any platform plugins in: " + path;
throw std::runtime_error(msg.c_str());
BOOST_THROW_EXCEPTION(std::runtime_error(msg.c_str()));
}

auto display_targets = the_display_platforms();
Expand Down

0 comments on commit 688d231

Please sign in to comment.