Skip to content

Fix uncaught util::exception#7324

Merged
DennisOSRM merged 2 commits intoProject-OSRM:masterfrom
MarcelloPerathoner:fix-uncaught-exceptions
Jan 12, 2026
Merged

Fix uncaught util::exception#7324
DennisOSRM merged 2 commits intoProject-OSRM:masterfrom
MarcelloPerathoner:fix-uncaught-exceptions

Conversation

@MarcelloPerathoner
Copy link
Copy Markdown
Contributor

Issue

Fixes #7323 util::exception is never caught

Tasklist

Requirements / Relations

Link any requirements here. Other pull requests this PR is based on?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #7323 by adding catch blocks for util::exception across six tool files to prevent uncaught exceptions. The util::exception class is the base exception class for OSRM, and osrm::RuntimeError (which was already being caught) inherits from it. This fix ensures that any util::exception that is not a RuntimeError will now be properly caught and logged.

Changes:

  • Added catch blocks for util::exception in six tool executables (store, routed, partition, extract, customize, contract)
  • Added explicit include of util/exception.hpp in extract.cpp
  • All catch blocks log the error and return EXIT_FAILURE

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/tools/store.cpp Added util::exception catch block after RuntimeError handler
src/tools/routed.cpp Added util::exception catch block after RuntimeError handler
src/tools/partition.cpp Added util::exception catch block with memory dump after RuntimeError handler
src/tools/extract.cpp Added util::exception catch block with memory dump and explicit include of util/exception.hpp
src/tools/customize.cpp Added util::exception catch block with memory dump after RuntimeError handler
src/tools/contract.cpp Added util::exception catch block with memory dump after RuntimeError handler

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tools/routed.cpp
return e.GetCode();
}
catch (const util::exception &e)
{
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The util::exception catch block should call util::DumpMemoryStats() for consistency with other tool files (extract.cpp, partition.cpp, customize.cpp, and contract.cpp). This helps with debugging memory-related issues when exceptions occur.

Suggested change
{
{
util::DumpMemoryStats();

Copilot uses AI. Check for mistakes.
Comment thread src/tools/extract.cpp
#include "osrm/exception.hpp"
#include "osrm/extractor.hpp"
#include "osrm/extractor_config.hpp"
#include "util/exception.hpp"
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explicit include of "util/exception.hpp" is redundant since "osrm/exception.hpp" (included at line 1) already includes "util/exception.hpp". Consider removing this line for consistency with other tool files (store.cpp, routed.cpp, partition.cpp, customize.cpp, contract.cpp) which rely on the transitive include.

Suggested change
#include "util/exception.hpp"

Copilot uses AI. Check for mistakes.
Comment thread src/tools/store.cpp
return e.GetCode();
}
catch (const util::exception &e)
{
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The util::exception catch block should call util::DumpMemoryStats() for consistency with other tool files (extract.cpp, partition.cpp, customize.cpp, and contract.cpp). This helps with debugging memory-related issues when exceptions occur.

Suggested change
{
{
util::DumpMemoryStats();

Copilot uses AI. Check for mistakes.
@DennisOSRM DennisOSRM merged commit cf4cdb3 into Project-OSRM:master Jan 12, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

util::exception is never caught

3 participants