catch
This commit is contained in:
parent
ebfda949ea
commit
95c409ad95
15
src/Tui.cpp
15
src/Tui.cpp
@ -70,10 +70,20 @@ void Tui::run() {
|
||||
if constexpr (std::is_same_v<T, Command::None>) {
|
||||
std::cout << "Invalid command!" << std::endl;
|
||||
} else if constexpr (std::is_same_v<T, Command::Next>) {
|
||||
try {
|
||||
m_page += 1;
|
||||
} catch (const std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
std::cout << m_page.str_pretty() << std::endl;
|
||||
} else if constexpr (std::is_same_v<T, Command::Previous>) {
|
||||
try {
|
||||
m_page -= 1;
|
||||
} catch (const std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
std::cout << m_page.str_pretty() << std::endl;
|
||||
} else if constexpr (std::is_same_v<T, Command::Refresh>) {
|
||||
m_page.refresh();
|
||||
@ -85,7 +95,12 @@ void Tui::run() {
|
||||
} else if constexpr (std::is_same_v<T, Command::Seek>) {
|
||||
const Command::Seek &seek = arg;
|
||||
const int number = seek.number;
|
||||
try {
|
||||
m_page = Page(number);
|
||||
} catch (const std::runtime_error &e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
std::cout << m_page.str_pretty() << std::endl;
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user