initial commits
parent
1e16f35451
commit
9d5e4af6b2
40
notfound.go
40
notfound.go
|
@ -2,6 +2,8 @@ package eol
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"sourcecode.social/reiver/go-opt"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ error = internalNotFoundError{}
|
var _ error = internalNotFoundError{}
|
||||||
|
@ -9,7 +11,15 @@ var _ error = internalNotFoundError{}
|
||||||
type internalNotFoundError struct{
|
type internalNotFoundError struct{
|
||||||
expected rune
|
expected rune
|
||||||
actual rune
|
actual rune
|
||||||
characterNumber uint64
|
circumstance internalCircumstance
|
||||||
|
}
|
||||||
|
|
||||||
|
func errNotFound(circumstance internalCircumstance, expected rune, actual rune) error {
|
||||||
|
return internalNotFoundError {
|
||||||
|
expected:expected,
|
||||||
|
actual:actual,
|
||||||
|
circumstance:circumstance,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver internalNotFoundError) Error() string {
|
func (receiver internalNotFoundError) Error() string {
|
||||||
|
@ -21,23 +31,39 @@ func (receiver internalNotFoundError) Error() string {
|
||||||
var expected rune = receiver.expected
|
var expected rune = receiver.expected
|
||||||
var actual rune = receiver.actual
|
var actual rune = receiver.actual
|
||||||
|
|
||||||
var characterNumber uint64 = receiver.characterNumber
|
var characterNumber uint64 = receiver.circumstance.CharacterNumber()
|
||||||
|
var eolSequence opt.Optional[string] = receiver.circumstance.EOLSequence()
|
||||||
|
|
||||||
switch expected {
|
switch expected {
|
||||||
case lf:
|
case lf:
|
||||||
var s string = fmt.Sprintf(`eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line character №%d — instead found %q (%U)`, characterNumber, actual, actual)
|
var s string = fmt.Sprintf(`eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence character №%d — instead found %q (%U)`, characterNumber, actual, actual)
|
||||||
|
eolSequence.WhenSomething(func(sequence string){
|
||||||
|
s = fmt.Sprintf(`eol: line-feed (LF) character ('\n') (U+000A) not found for end-of-line sequence %q character №%d — instead found %q (%U)`, sequence, characterNumber, actual, actual)
|
||||||
|
})
|
||||||
p = append(p, s...)
|
p = append(p, s...)
|
||||||
case cr:
|
case cr:
|
||||||
var s string = fmt.Sprintf(`eol: carriage-return (CR) character ('\r') (U+000D) not found for end-of-line character №%d — instead found %q (%U)`, characterNumber, actual, actual)
|
var s string = fmt.Sprintf(`eol: carriage-return (CR) character ('\r') (U+000D) not found for end-of-line sequence character №%d — instead found %q (%U)`, characterNumber, actual, actual)
|
||||||
|
eolSequence.WhenSomething(func(sequence string){
|
||||||
|
s = fmt.Sprintf(`eol: carriage-return (CR) character ('\r') (U+000D) not found for end-of-line sequence %q character №%d — instead found %q (%U)`, sequence, characterNumber, actual, actual)
|
||||||
|
})
|
||||||
p = append(p, s...)
|
p = append(p, s...)
|
||||||
case nel:
|
case nel:
|
||||||
var s string = fmt.Sprintf(`eol: next-line (NEL) character (U+0085) not found for end-of-line character №%d — instead found %q (%U)`, characterNumber, actual, actual)
|
var s string = fmt.Sprintf(`eol: next-line (NEL) character (U+0085) not found for end-of-line sequence character №%d — instead found %q (%U)`, characterNumber, actual, actual)
|
||||||
|
eolSequence.WhenSomething(func(sequence string){
|
||||||
|
s = fmt.Sprintf(`eol: next-line (NEL) character (U+0085) not found for end-of-line sequence %q character №%d — instead found %q (%U)`, sequence, characterNumber, actual, actual)
|
||||||
|
})
|
||||||
p = append(p, s...)
|
p = append(p, s...)
|
||||||
case ls:
|
case ls:
|
||||||
var s string = fmt.Sprintf(`eol: line-separator (LS) character (U+2028) not found for end-of-line character №%d — instead found %q (%U)`, characterNumber, actual, actual)
|
var s string = fmt.Sprintf(`eol: line-separator (LS) character (U+2028) not found for end-of-line sequence character №%d — instead found %q (%U)`, characterNumber, actual, actual)
|
||||||
|
eolSequence.WhenSomething(func(sequence string){
|
||||||
|
s = fmt.Sprintf(`eol: line-separator (LS) character (U+2028) not found for end-of-line sequence %q character №%d — instead found %q (%U)`, sequence, characterNumber, actual, actual)
|
||||||
|
})
|
||||||
p = append(p, s...)
|
p = append(p, s...)
|
||||||
default:
|
default:
|
||||||
var s string = fmt.Sprintf(`eol: %q character (%U) not found for character №%d — instead found %q (%U)`, expected, expected, characterNumber, actual, actual)
|
var s string = fmt.Sprintf(`eol: %q character (%U) not found for sequence character №%d — instead found %q (%U)`, expected, expected, characterNumber, actual, actual)
|
||||||
|
eolSequence.WhenSomething(func(sequence string){
|
||||||
|
s = fmt.Sprintf(`eol: %q character (%U) not found for sequence %q character №%d — instead found %q (%U)`, expected, expected, sequence, characterNumber, actual, actual)
|
||||||
|
})
|
||||||
p = append(p, s...)
|
p = append(p, s...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,23 +6,29 @@ import (
|
||||||
|
|
||||||
var _ error = internalProblemReadingRuneError{}
|
var _ error = internalProblemReadingRuneError{}
|
||||||
|
|
||||||
func errProblemReadingRune(err error, runeNumber uint64) error {
|
func errProblemReadingRune(circumstance internalCircumstance, err error) error {
|
||||||
return internalProblemReadingRuneError{
|
return internalProblemReadingRuneError{
|
||||||
err:err,
|
err:err,
|
||||||
runeNumber:runeNumber,
|
circumstance:circumstance,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type internalProblemReadingRuneError struct {
|
type internalProblemReadingRuneError struct {
|
||||||
err error
|
err error
|
||||||
runeNumber uint64
|
circumstance internalCircumstance
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver internalProblemReadingRuneError) Error() string {
|
func (receiver internalProblemReadingRuneError) Error() string {
|
||||||
err := receiver.err
|
err := receiver.err
|
||||||
runeNumber := receiver.runeNumber
|
characterNumber := receiver.circumstance.CharacterNumber()
|
||||||
|
eolSequence := receiver.circumstance.EOLSequence()
|
||||||
|
|
||||||
return fmt.Sprintf("eol: problem reading character №%d of end-of-line sequence: %s", runeNumber, err)
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver internalProblemReadingRuneError) Unwrap() error {
|
func (receiver internalProblemReadingRuneError) Unwrap() error {
|
||||||
|
|
|
@ -6,26 +6,32 @@ import (
|
||||||
|
|
||||||
var _ error = internalProblemUnreadingRuneError{}
|
var _ error = internalProblemUnreadingRuneError{}
|
||||||
|
|
||||||
func errProblemUnreadingRune(err error, runeNumber uint64, r rune) error {
|
func errProblemUnreadingRune(circumstance internalCircumstance, err error, r rune) error {
|
||||||
return internalProblemUnreadingRuneError{
|
return internalProblemUnreadingRuneError{
|
||||||
err:err,
|
err:err,
|
||||||
runeNumber:runeNumber,
|
|
||||||
r:r,
|
r:r,
|
||||||
|
circumstance:circumstance,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type internalProblemUnreadingRuneError struct {
|
type internalProblemUnreadingRuneError struct {
|
||||||
err error
|
err error
|
||||||
runeNumber uint64
|
|
||||||
r rune
|
r rune
|
||||||
|
circumstance internalCircumstance
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver internalProblemUnreadingRuneError) Error() string {
|
func (receiver internalProblemUnreadingRuneError) Error() string {
|
||||||
err := receiver.err
|
err := receiver.err
|
||||||
runeNumber := receiver.runeNumber
|
|
||||||
r := receiver.r
|
r := receiver.r
|
||||||
|
characterNumber := receiver.circumstance.CharacterNumber()
|
||||||
|
eolSequence := receiver.circumstance.EOLSequence()
|
||||||
|
|
||||||
return fmt.Sprintf("eol: problem unreading character №%d (%q (%U)) of end-of-line sequence: %s", runeNumber, r, r, err)
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
func (receiver internalProblemUnreadingRuneError) Unwrap() error {
|
func (receiver internalProblemUnreadingRuneError) Unwrap() error {
|
||||||
|
|
Loading…
Reference in New Issue