1package magna
2
3import (
4 "fmt"
5)
6
7// BufferOverflowError represents an error when there is a buffer overflow.
8type BufferOverflowError struct {
9 Length int
10 Offset int
11}
12
13func (e *BufferOverflowError) Error() string {
14 return fmt.Sprintf("magna: offset %d is past the buffer length %d", e.Offset, e.Length)
15}
16
17// InvalidLabelError represents an error when an invalid label length is encountered.
18type InvalidLabelError struct {
19 Length int
20}
21
22func (e *InvalidLabelError) Error() string {
23 return fmt.Sprintf("magna: received invalid label length %d", e.Length)
24}
25
26// DomainCompressionError represents an error related to domain compression.
27type DomainCompressionError struct{}
28
29func (e *DomainCompressionError) Error() string {
30 return "magna: loop detected in domain compression"
31}
32
33// MagnaError represents a generic error with a custom message.
34type MagnaError struct {
35 Message string
36}
37
38func (e *MagnaError) Error() string {
39 return fmt.Sprintf("magna: %s", e.Message)
40}