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