diff options
| author | Mroik <mroik@delayed.space> | 2025-01-30 17:56:10 +0100 |
|---|---|---|
| committer | Mroik <mroik@delayed.space> | 2025-02-01 19:34:42 +0100 |
| commit | 59fabdcc08491c2e117d36d54b481f3dbc21f7ca (patch) | |
| tree | b0eb9b911de1626c5ff361060518a44f9dfc8522 /src/error.rs | |
| parent | 560b66bd51271210f9d8bc340fd80f54b9989026 (diff) | |
Fix error text
Diffstat (limited to 'src/error.rs')
| -rw-r--r-- | src/error.rs | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/error.rs b/src/error.rs index 9474203..4d4f4ab 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,21 +1,28 @@ use std::{error::Error, fmt::Display}; +use crate::app::{MIN_TERM_COL, MIN_TERM_ROW}; + #[derive(Debug, Clone)] pub struct WordTooLongError { word: String, + max_length: u16, } impl WordTooLongError { - pub fn new(word: impl Into<String>) -> WordTooLongError { - WordTooLongError { word: word.into() } + pub fn new(word: impl Into<String>, max_length: u16) -> WordTooLongError { + WordTooLongError { + word: word.into(), + max_length, + } } } impl Display for WordTooLongError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!( - "The word \"{}\" is too long for the current terminal size or longer than 80 characters.", - self.word + "The word \"{}\" is too long for the current terminal size or longer than {} characters.", + self.word, + self.max_length, )) } } @@ -27,9 +34,10 @@ pub struct TerminalTooSmallError; impl Display for TerminalTooSmallError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str( - "The terminal size is too small. Min column count is 65 and minimum row count is 15.", - ) + f.write_fmt(format_args!( + "The terminal size is too small. Min column count is {} and minimum row count is {}.", + MIN_TERM_COL, MIN_TERM_ROW + )) } } |
