go-eol/problemreadingrune.go

37 lines
941 B
Go
Raw Normal View History

2023-11-28 14:26:36 +00:00
package eol
import (
"fmt"
)
var _ error = internalProblemReadingRuneError{}
2023-11-28 16:04:21 +00:00
func errProblemReadingRune(circumstance internalCircumstance, err error) error {
2023-11-28 14:26:36 +00:00
return internalProblemReadingRuneError{
err:err,
2023-11-28 16:04:21 +00:00
circumstance:circumstance,
2023-11-28 14:26:36 +00:00
}
}
type internalProblemReadingRuneError struct {
err error
2023-11-28 16:04:21 +00:00
circumstance internalCircumstance
2023-11-28 14:26:36 +00:00
}
func (receiver internalProblemReadingRuneError) Error() string {
err := receiver.err
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 reading character №%d of end-of-line sequence: %s", characterNumber, err)
eolSequence.WhenSomething(func(sequence string){
s = fmt.Sprintf("eol: problem reading character №%d of end-of-line sequence %q: %s", characterNumber, sequence, err)
})
return s
2023-11-28 14:26:36 +00:00
}
func (receiver internalProblemReadingRuneError) Unwrap() error {
return receiver.err
}