Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 7, 2025

The Reader constructor in src/ifc-reader/reader.cxx was throwing a built-in type (string literal) which violates C++ Core Guidelines E.14:

// Before - violates Core Guidelines E.14
if (not ifc.header())
    throw "file not found";  // ❌ Throwing built-in type
// After - complies with Core Guidelines E.14
if (not ifc.header())
    throw InputIfc::IfcHeaderNotAvailable{};  // ✅ Proper exception type

Changes Made

  1. Added new exception type IfcHeaderNotAvailable in include/ifc/file.hxx

    • Follows the same pattern as other exception types like IllFormedPartitionName
    • Placed within InputIfc struct to indicate the context
    • No parameters required since the Reader constructor doesn't have access to path information
  2. Updated Reader constructor to use the proper exception type instead of throwing a string literal

Context

The Reader constructor checks if ifc.header() returns a valid pointer. The header is only initialized when validate() is called on the InputIfc object. The fix creates a proper exception type that accurately describes the error condition (header not available) without requiring additional parameters that aren't available in the constructor context.

Verification

  • ✅ Code builds successfully
  • ✅ No other built-in type exceptions found in codebase
  • ✅ Exception type compiles and works correctly
  • ✅ Code formatting applied with clang-format

This change ensures full compliance with C++ Core Guidelines E.14: "Don't throw built-in types".

Fixes #33.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: gdr-at-ms <11031650+gdr-at-ms@users.noreply.github.com>
Copilot AI changed the title [WIP] Don't throw exception of built-in types Fix built-in type exception throwing to comply with Core Guidelines E.14 Jul 7, 2025
Copilot AI requested a review from gdr-at-ms July 7, 2025 19:43
@gdr-at-ms
Copy link
Member

  1. Rename the new exception to MissingIfcHeader
  2. Find all the places where the constructor is called

Co-authored-by: gdr-at-ms <11031650+gdr-at-ms@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 7, 2025

  1. Rename the new exception to MissingIfcHeader
  2. Find all the places where the constructor is called
  1. Done - renamed exception to MissingIfcHeader in 69f824b
  2. Found all places where the Reader constructor is called:
    • src/ifc-printer/main.cxx:116: ifc::Reader reader(file);
    • test/basic.cxx:180: return Reader{ *ifc };

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@gdr-at-ms
Copy link
Member

Don't apply clang-format

Copy link
Contributor Author

Copilot AI commented Jul 7, 2025

Don't apply clang-format

Understood - I will not apply clang-format to the code. The current changes will remain as-is without automatic formatting.

@gdr-at-ms
Copy link
Member

Are you still working on the draft?

@gdr-at-ms gdr-at-ms marked this pull request as ready for review July 9, 2025 10:25
@gdr-at-ms gdr-at-ms merged commit f8b0403 into main Jul 9, 2025
7 checks passed
@gdr-at-ms gdr-at-ms deleted the copilot/fix-33 branch July 9, 2025 10:28
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.

Don't throw exception of built-in types

3 participants