File: errors.go

package info (click to toggle)
golang-github-dromara-dongle 1.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,440 kB
  • sloc: makefile: 4
file content (37 lines) | stat: -rw-r--r-- 1,368 bytes parent folder | download
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)
}