(&self, vm: &VirtualMachine)
| 854 | |
| 855 | impl ToPyException for Base64DecodeError { |
| 856 | fn to_pyexception(&self, vm: &VirtualMachine) -> PyBaseExceptionRef { |
| 857 | use base64::DecodeError::*; |
| 858 | let message = match &self.0 { |
| 859 | InvalidByte(0, PAD) => "Leading padding not allowed".to_owned(), |
| 860 | InvalidByte(_, PAD) => "Discontinuous padding not allowed".to_owned(), |
| 861 | InvalidByte(_, _) => "Only base64 data is allowed".to_owned(), |
| 862 | InvalidLastSymbol(_, PAD) => "Excess data after padding".to_owned(), |
| 863 | InvalidLastSymbol(length, _) => { |
| 864 | format!( |
| 865 | "Invalid base64-encoded string: number of data characters {length} cannot be 1 more than a multiple of 4" |
| 866 | ) |
| 867 | } |
| 868 | // TODO: clean up errors |
| 869 | InvalidLength(_) => "Incorrect padding".to_owned(), |
| 870 | InvalidPadding => "Incorrect padding".to_owned(), |
| 871 | }; |
| 872 | new_binascii_error(format!("error decoding base64: {message}"), vm) |
| 873 | } |
| 874 | } |
no test coverage detected