Skip to content

fix: make VsagException public inherit from std::exception#1787

Open
inabao wants to merge 3 commits into0.17from
cp-1776-to-0.17
Open

fix: make VsagException public inherit from std::exception#1787
inabao wants to merge 3 commits into0.17from
cp-1776-to-0.17

Conversation

@inabao
Copy link
Copy Markdown
Collaborator

@inabao inabao commented Mar 31, 2026

Summary

Cherry-pick of PR #1776 to branch 0.17

  • Fix VsagException to use public inheritance from std::exception instead of private inheritance
  • Reorder catch blocks in engine.cpp to ensure VsagException is caught before std::exception
  • This allows VsagException to be caught by catch (std::exception& e) handlers, following standard C++ exception handling patterns

Problem

The class was using private inheritance (default for class):

class VsagException : std::exception {  // private inheritance

This prevented catching VsagException with std::exception handler, breaking standard exception handling.

Solution

Changed to public inheritance:

class VsagException : public std::exception {

And reordered catch blocks to ensure derived class (VsagException) is caught before base class (std::exception).

Changes

  1. src/vsag_exception.h: Changed to public inheritance
  2. src/factory/engine.cpp: Reordered catch blocks (VsagException before std::exception)

Impact

  • No breaking changes - all existing code behavior unchanged
  • Adds ability to catch VsagException via std::exception handler
  • Follows C++ standard practice for exception classes

inabao and others added 3 commits March 10, 2026 16:26
Move max_capacity assignment after io->Write() to ensure data is persisted before updating capacity.

Co-Authored-By: Claude <[email protected]>
Signed-off-by: jinjiabao.jjb <[email protected]>
The class was using private inheritance which prevented catching
VsagException with std::exception handler, breaking standard C++
exception handling patterns.

Signed-off-by: jinjiabao.jjb <[email protected]>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the VsagException class to use public inheritance from std::exception and reorders the catch blocks in Engine::CreateIndex to ensure that the more specific VsagException is caught before the general std::exception. I have no feedback to provide.

@inabao inabao added the kind/bug Something isn't working label Mar 31, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             0.17    #1787      +/-   ##
==========================================
- Coverage   91.90%   91.46%   -0.44%     
==========================================
  Files         318      318              
  Lines       17758    17758              
==========================================
- Hits        16320    16243      -77     
- Misses       1438     1515      +77     
Flag Coverage Δ
cpp 91.46% <100.00%> (-0.44%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
common 91.75% <ø> (ø)
datacell 93.20% <ø> (-0.04%) ⬇️
index 90.62% <ø> (-0.30%) ⬇️
simd 100.00% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c35ce5...79e08d0. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@LHT129 LHT129 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/XS version/0.17

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants