| 1 |
package base32 |
| 2 |
|
| 3 |
import "fmt" |
| 4 |
|
| 5 |
// AlphabetSizeError represents an error when the base32 alphabet is invalid. |
| 6 |
// Base32 requires an alphabet of exactly 32 characters for proper encoding |
| 7 |
// and decoding operations. This error occurs when the alphabet length |
| 8 |
// does not meet this requirement. |
| 9 |
type AlphabetSizeError int |
| 10 |
|
| 11 |
// Error returns a formatted error message describing the invalid alphabet length. |
| 12 |
// The message includes the actual length and the required length for debugging. |
| 13 |
func (e AlphabetSizeError) Error() string { |
| 14 |
return fmt.Sprintf("coding/base32: invalid alphabet, the alphabet length must be 32, got %d", int(e)) |
| 15 |
} |
| 16 |
|
| 17 |
// CorruptInputError represents an error when corrupted or invalid base32 data |
| 18 |
// is detected during decoding. This error occurs when an invalid character |
| 19 |
// is found in the input or when the input data is malformed. |
| 20 |
type CorruptInputError int64 |
| 21 |
|
| 22 |
// Error returns a formatted error message describing the corrupted input. |
| 23 |
// The message includes the position where corruption was detected. |
| 24 |
func (e CorruptInputError) Error() string { |
| 25 |
return fmt.Sprintf("coding/base32: illegal data at input byte %d", int64(e)) |
| 26 |
} |