diff --git a/src/ExprNode.hh b/src/ExprNode.hh
index dfdd75ed2be6d361aee9af04976763f6ddad346b..491379cde8277570acc3d053aca1e13ad0425908 100644
--- a/src/ExprNode.hh
+++ b/src/ExprNode.hh
@@ -919,9 +919,11 @@ public:
   [[nodiscard]] virtual pair<int, expr_t> matchEndogenousTimesConstant() const;
 
   //! Exception thrown when matching fails
-  struct MatchFailureException
+  class MatchFailureException
   {
+  public:
     const string message;
+    MatchFailureException(string message_arg) : message(message_arg) {}
   };
 
   /* Match an expression of the form ∏ x(l)ᵏ, where x are endogenous, as used