summaryrefslogtreecommitdiff
path: root/src/package.cpp
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2023-04-15 08:43:30 +0200
committerEugen Wissner <belka@caraus.de>2023-04-15 08:43:30 +0200
commit34b10f41aa285e423cccb161342b68ae7275da4b (patch)
treee021c107400ec467b59a019c45d6659110c677cf /src/package.cpp
parentdbf14caee2f3ffbcfb21d5ca4d1566e0f57a1aed (diff)
downloadslackbuilder-34b10f41aa285e423cccb161342b68ae7275da4b.tar.gz
Retrieve updatable packages
Diffstat (limited to 'src/package.cpp')
-rw-r--r--src/package.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/package.cpp b/src/package.cpp
index 0734a5e..9fc99e4 100644
--- a/src/package.cpp
+++ b/src/package.cpp
@@ -73,4 +73,34 @@ namespace katja
}
return packages;
}
+
+ package_exception::package_exception(const std::string& package_name, const std::string& reason) noexcept
+ : m_message(package_name)
+ {
+ m_message.reserve(m_message.size() + 2 + reason.size());
+ m_message += ": " + reason;
+ }
+
+ const std::string_view package_exception::package_name() const noexcept
+ {
+ std::size_t colon_position = m_message.find(':');
+
+ if (colon_position == std::string::npos)
+ {
+ return std::string_view(m_message);
+ }
+ else if (colon_position == 0)
+ {
+ return std::string_view("");
+ }
+ else
+ {
+ return std::string_view(m_message.c_str(), colon_position - 1);
+ }
+ }
+
+ const char *package_exception::what() const noexcept
+ {
+ return m_message.c_str();
+ }
}