1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
package unicode
import "fmt"
// DecodeFailedError represents an error when unicode decoding fails.
// This error occurs when invalid unicode escape sequences are encountered
// during decoding operations.
type DecodeFailedError struct {
Input string // The invalid input that caused the error
}
// Error returns a formatted error message describing the decode failure.
func (e DecodeFailedError) Error() string {
return fmt.Sprintf("coding/unicode: failed to decode data: %s", e.Input)
}
// InvalidUnicodeError represents an error when invalid unicode data is encountered.
// This error occurs when malformed unicode escape sequences are found.
type InvalidUnicodeError struct {
Char string // The invalid unicode character that was found
}
// Error returns a formatted error message describing the invalid unicode.
func (e InvalidUnicodeError) Error() string {
return fmt.Sprintf("coding/unicode: invalid unicode character: %s", e.Char)
}
// EncodeFailedError represents an error when unicode encoding fails.
// This error is rarely used since strconv.QuoteToASCII rarely fails.
type EncodeFailedError struct {
Input string // The input that failed to encode
}
// Error returns a formatted error message describing the encode failure.
func (e EncodeFailedError) Error() string {
return fmt.Sprintf("coding/unicode: failed to encode data: %s", e.Input)
}
|