commit 1fc5cb9b9fefed28cfeaaf96122b62ebb8c38ad5
parent fb4f0394209f42fa8931ca02bb68c0a2557817c8
Author: Andrew Laack <andrew@laack.co>
Date: Sat, 3 Oct 2026 15:51:49 -0500
Refactoring exceptions
Diffstat:
6 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -6,4 +6,5 @@ coverage-html/
*.info
*.folded
*.data
+*.data.old
*.svg
diff --git a/Makefile b/Makefile
@@ -60,6 +60,11 @@ flamegraph:
perf script | ~/gitRepos/FlameGraph/stackcollapse-perf.pl > out.folded
~/gitRepos/FlameGraph/flamegraph.pl out.folded > flamegraph.svg
+run-graph: build
+ perf record -g ./foreseen.out
+ perf script | ~/gitRepos/FlameGraph/stackcollapse-perf.pl > out.folded
+ ~/gitRepos/FlameGraph/flamegraph.pl out.folded > flamegraph.svg
+
test: pure-test browser-test fetch-test puppet-test
lcov --capture --directory . --output-file coverage.info \
--no-external \
diff --git a/include/errors.hpp b/include/errors.hpp
@@ -2,18 +2,6 @@
#include <stdexcept>
-class NotImplemented : public std::logic_error
-{
-public:
- NotImplemented() : std::logic_error("Function not yet implemented") { };
-};
-
-
-class BrowserStartError : public std::logic_error {
- public:
- BrowserStartError() : std::logic_error("An issue occurred while creating the browser") { };
-};
-
class FileReadError : public std::invalid_argument
{
public:
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -1,6 +1,7 @@
#include "../include/browser.hpp"
#include <cassert>
#include <filesystem>
+#include <stdexcept>
#include <string>
#include <thread>
#include <unistd.h>
@@ -273,7 +274,7 @@ Browser::Browser() : threads(THREAD_NUM), done(THREAD_NUM){
// this ensures some nice invariants about the browser, like always having at least one valid page.
bool start = goToSite("about://newtab");
if(!start) {
- throw BrowserStartError{};
+ throw std::runtime_error("Browser unexpectedly failed to start.");
}
}
diff --git a/src/gemini-client.cpp b/src/gemini-client.cpp
@@ -166,8 +166,6 @@ Site* GeminiClient::fetchSite(Link link, std::string crtPath, std::string keyPat
} else if(isPrefixed(destination, "about://")){
return new Site {"20 text/gemini", getNewTab()};
} else {
- throw NotImplemented();
+ throw std::runtime_error("An invalid argument was passed to fetchsite, " + destination);
}
-
- throw NotImplemented();
}
diff --git a/src/heading.cpp b/src/heading.cpp
@@ -3,6 +3,7 @@
#include "../include/utils.hpp"
#include <cstdint>
#include <ncurses.h>
+#include <stdexcept>
Heading::Heading(std::string text) : actualText(text) {
@@ -33,7 +34,7 @@ std::string Heading::textToDraw() {
case 1:
return "# " + toDraw + "\n";
}
- throw NotImplemented();
+ throw std::runtime_error("This is an invalid program state.");
}
uint8_t Heading::getColor() {
switch (headingLevel) {
@@ -44,7 +45,7 @@ uint8_t Heading::getColor() {
case 1:
return COLOR_RED;
}
- throw NotImplemented();
+ throw std::runtime_error("This is an invalid program state.");
}
LineType Heading::type() {
switch (headingLevel) {
@@ -55,7 +56,7 @@ LineType Heading::type() {
case 1:
return H1;
}
- throw NotImplemented();
+ throw std::runtime_error("This is an invalid program state.");
}
bool Heading::isBold() {
return true;