Skip to content

Commit

Permalink
Detect missing error messages (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcauberer authored Feb 15, 2025
1 parent b40111a commit c2f93e9
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/exception/CliError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "CliError.h"

#include <util/GlobalDefinitions.h>

namespace spice::compiler {

/**
Expand Down Expand Up @@ -44,7 +46,8 @@ std::string CliError::getMessagePrefix(CliErrorType errorType) {
case COMING_SOON_CLI:
return "Coming soon";
}
return "Unknown error";
assert_fail("Unknown error"); // GCOV_EXCL_LINE
return "Unknown error"; // GCOV_EXCL_LINE
}

} // namespace spice::compiler
3 changes: 2 additions & 1 deletion src/exception/CompilerError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ std::string CompilerError::getMessagePrefix(CompilerErrorType errorType) {
case INVALID_MODULE: // LCOV_EXCL_LINE
return "Invalid module"; // LCOV_EXCL_LINE
}
return "Unknown error"; // GCOV_EXCL_LINE
assert_fail("Unknown error"); // GCOV_EXCL_LINE
return "Unknown error"; // GCOV_EXCL_LINE
}

} // namespace spice::compiler
1 change: 1 addition & 0 deletions src/exception/LexerError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ std::string LexerError::getMessagePrefix(LexerErrorType errorType) {
case TOKENIZING_FAILED:
return "Tokenizing failed";
}
assert_fail("Unknown error"); // GCOV_EXCL_LINE
return "Unknown error"; // GCOV_EXCL_LINE
}

Expand Down
5 changes: 4 additions & 1 deletion src/exception/LinkerError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "LinkerError.h"

#include <util/GlobalDefinitions.h>

namespace spice::compiler {

/**
Expand Down Expand Up @@ -32,7 +34,8 @@ std::string LinkerError::getMessagePrefix(LinkerErrorType errorType) {
case LINKER_ERROR:
return "Linker error occurred";
}
return "Unknown error"; // GCOV_EXCL_LINE
assert_fail("Unknown error"); // GCOV_EXCL_LINE
return "Unknown error"; // GCOV_EXCL_LINE
}

} // namespace spice::compiler
3 changes: 2 additions & 1 deletion src/exception/ParserError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ std::string ParserError::getMessagePrefix(ParserErrorType errorType) {
case RESERVED_KEYWORD:
return "Usage of reserved keyword";
}
return "Unknown error"; // GCOV_EXCL_LINE
assert_fail("Unknown error"); // GCOV_EXCL_LINE
return "Unknown error"; // GCOV_EXCL_LINE
}

} // namespace spice::compiler
3 changes: 2 additions & 1 deletion src/exception/SemanticError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ std::string SemanticError::getMessagePrefix(SemanticErrorType errorType) {
case COMING_SOON_SA:
return "Coming soon";
}
return "Unknown error"; // GCOV_EXCL_LINE
assert_fail("Unknown error"); // GCOV_EXCL_LINE
return "Unknown error"; // GCOV_EXCL_LINE
}

} // namespace spice::compiler
3 changes: 2 additions & 1 deletion src/util/CompilerWarning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ std::string CompilerWarning::getMessagePrefix(CompilerWarningType warningType) {
case VERIFIER_DISABLED:
return "Verifier disabled";
}
return "Unknown warning"; // GCOV_EXCL_LINE
assert_fail("Unknown warning"); // GCOV_EXCL_LINE
return "Unknown warning"; // GCOV_EXCL_LINE
}

} // namespace spice::compiler

0 comments on commit c2f93e9

Please sign in to comment.