go-eol/problemunreadingrune.go

40 lines
1.0 KiB
Go
Raw Normal View History

2023-11-28 14:26:36 +00:00
package eol
import (
"fmt"
)
var _ error = internalProblemUnreadingRuneError{}
2023-11-28 16:04:21 +00:00
func errProblemUnreadingRune(circumstance internalCircumstance, err error, r rune) error {
2023-11-28 14:26:36 +00:00
return internalProblemUnreadingRuneError{
err:err,
r:r,
2023-11-28 16:04:21 +00:00
circumstance:circumstance,
2023-11-28 14:26:36 +00:00
}
}
type internalProblemUnreadingRuneError struct {
err error
r rune
2023-11-28 16:04:21 +00:00
circumstance internalCircumstance
2023-11-28 14:26:36 +00:00
}
func (receiver internalProblemUnreadingRuneError) Error() string {
err := receiver.err
r := receiver.r
2023-11-28 16:04:21 +00:00
characterNumber := receiver.circumstance.CharacterNumber()
eolSequence := receiver.circumstance.EOLSequence()
2023-11-28 14:26:36 +00:00
2023-11-28 16:04:21 +00:00
var s string = fmt.Sprintf("eol: problem unreading character №%d (%q (%U)) of end-of-line sequence: %s", characterNumber, r, r, err)
eolSequence.WhenSomething(func(sequence string){
s = fmt.Sprintf("eol: problem unreading character №%d (%q (%U)) of end-of-line sequence %q: %s", characterNumber, r, r, sequence, err)
})
return s
2023-11-28 14:26:36 +00:00
}
func (receiver internalProblemUnreadingRuneError) Unwrap() error {
return receiver.err
}