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 (25 lines) | stat: -rw-r--r-- 1,115 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
package base100

import "fmt"

// InvalidLengthError represents an error when the base100 input length is invalid.
// Base100 encoding requires each input byte to be represented by exactly 4 bytes,
// so the input length must be divisible by 4 for proper decoding.
type InvalidLengthError int

// Error returns a formatted error message describing the invalid length.
// The message includes the actual length and the requirement for debugging.
func (e InvalidLengthError) Error() string {
	return fmt.Sprintf("coding/base100: invalid length, data length must be divisible by 4, got %d", int(e))
}

// CorruptInputError represents an error when corrupted or invalid base100 data
// is detected during decoding. This error occurs when an invalid character
// is found in the input or when the input data is malformed.
type CorruptInputError int64

// Error returns a formatted error message describing the corrupted input.
// The message includes the position where corruption was detected.
func (e CorruptInputError) Error() string {
	return fmt.Sprintf("coding/base100: illegal data at input byte %d", int64(e))
}