|
1 | 1 | #![allow(dead_code, clippy::wildcard_imports, clippy::needless_range_loop)] |
2 | 2 |
|
3 | 3 | // IEMSI autologin implementation http://ftsc.org/docs/fsc-0056.001 |
4 | | -use std::{ |
5 | | - fmt, |
6 | | - io::{self, ErrorKind}, |
7 | | -}; |
| 4 | +use std::fmt; |
8 | 5 |
|
9 | 6 | use icy_engine::{get_crc16, get_crc32, update_crc32}; |
10 | 7 |
|
@@ -304,10 +301,7 @@ impl EmsiICI { |
304 | 301 | ])?; |
305 | 302 |
|
306 | 303 | if data.len() > EmsiICI::MAX_SIZE { |
307 | | - return Err(Box::new(io::Error::new( |
308 | | - ErrorKind::OutOfMemory, |
309 | | - "maximum size exceeded", |
310 | | - ))); |
| 304 | + return Err(anyhow::anyhow!("maximum size exceeded")); |
311 | 305 | } |
312 | 306 | let mut result = Vec::new(); |
313 | 307 | result.extend_from_slice(b"**EMSI_ICI"); |
@@ -651,10 +645,7 @@ fn parse_emsi_blocks(data: &[u8]) -> TerminalResult<Vec<String>> { |
651 | 645 | i += 3; |
652 | 646 | continue; |
653 | 647 | } |
654 | | - return Err(Box::new(io::Error::new( |
655 | | - ErrorKind::InvalidData, |
656 | | - "Escape char in emsi string invalid.", |
657 | | - ))); |
| 648 | + return Err(anyhow::anyhow!("Escape char in emsi string invalid.")); |
658 | 649 | } |
659 | 650 |
|
660 | 651 | str.push(char::from_u32(u32::from(data[i])).unwrap()); |
@@ -686,10 +677,7 @@ fn encode_emsi(data: &[&str]) -> TerminalResult<Vec<u8>> { |
686 | 677 | } |
687 | 678 | let val = ch as u32; |
688 | 679 | if val > 255 { |
689 | | - return Err(Box::new(io::Error::new( |
690 | | - ErrorKind::InvalidData, |
691 | | - "Unicode chars not supported", |
692 | | - ))); |
| 680 | + return Err(anyhow::anyhow!("Unicode chars not supported")); |
693 | 681 | } |
694 | 682 | // control codes. |
695 | 683 | if val < 32 || val == 127 { |
|
0 commit comments