summaryrefslogtreecommitdiff
path: root/vendor/github.com/pelletier/go-toml/v2/errors.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2022-12-27 08:29:42 +0000
committerLibravatar GitHub <noreply@github.com>2022-12-27 08:29:42 +0000
commitb966d3b15712f645b53bc2396fdd29f4ce706850 (patch)
treeb86d17b6c153fd97d31b12bc581f83778101aa19 /vendor/github.com/pelletier/go-toml/v2/errors.go
parent[chore]: Bump codeberg.org/gruf/go-bytesize from 1.0.0 to 1.0.2 (#1285) (diff)
downloadgotosocial-b966d3b15712f645b53bc2396fdd29f4ce706850.tar.xz
[chore]: Bump github.com/gin-gonic/gin from 1.8.1 to 1.8.2 (#1286)
Bumps [github.com/gin-gonic/gin](https://github.com/gin-gonic/gin) from 1.8.1 to 1.8.2. - [Release notes](https://github.com/gin-gonic/gin/releases) - [Changelog](https://github.com/gin-gonic/gin/blob/master/CHANGELOG.md) - [Commits](https://github.com/gin-gonic/gin/compare/v1.8.1...v1.8.2) --- updated-dependencies: - dependency-name: github.com/gin-gonic/gin dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/pelletier/go-toml/v2/errors.go')
-rw-r--r--vendor/github.com/pelletier/go-toml/v2/errors.go32
1 files changed, 7 insertions, 25 deletions
diff --git a/vendor/github.com/pelletier/go-toml/v2/errors.go b/vendor/github.com/pelletier/go-toml/v2/errors.go
index 2e7f0ffdf..309733f1f 100644
--- a/vendor/github.com/pelletier/go-toml/v2/errors.go
+++ b/vendor/github.com/pelletier/go-toml/v2/errors.go
@@ -6,6 +6,7 @@ import (
"strings"
"github.com/pelletier/go-toml/v2/internal/danger"
+ "github.com/pelletier/go-toml/v2/unstable"
)
// DecodeError represents an error encountered during the parsing or decoding
@@ -55,25 +56,6 @@ func (s *StrictMissingError) String() string {
type Key []string
-// internal version of DecodeError that is used as the base to create a
-// DecodeError with full context.
-type decodeError struct {
- highlight []byte
- message string
- key Key // optional
-}
-
-func (de *decodeError) Error() string {
- return de.message
-}
-
-func newDecodeError(highlight []byte, format string, args ...interface{}) error {
- return &decodeError{
- highlight: highlight,
- message: fmt.Errorf(format, args...).Error(),
- }
-}
-
// Error returns the error message contained in the DecodeError.
func (e *DecodeError) Error() string {
return "toml: " + e.message
@@ -105,12 +87,12 @@ func (e *DecodeError) Key() Key {
// highlight can be freely deallocated.
//
//nolint:funlen
-func wrapDecodeError(document []byte, de *decodeError) *DecodeError {
- offset := danger.SubsliceOffset(document, de.highlight)
+func wrapDecodeError(document []byte, de *unstable.ParserError) *DecodeError {
+ offset := danger.SubsliceOffset(document, de.Highlight)
errMessage := de.Error()
errLine, errColumn := positionAtEnd(document[:offset])
- before, after := linesOfContext(document, de.highlight, offset, 3)
+ before, after := linesOfContext(document, de.Highlight, offset, 3)
var buf strings.Builder
@@ -140,7 +122,7 @@ func wrapDecodeError(document []byte, de *decodeError) *DecodeError {
buf.Write(before[0])
}
- buf.Write(de.highlight)
+ buf.Write(de.Highlight)
if len(after) > 0 {
buf.Write(after[0])
@@ -158,7 +140,7 @@ func wrapDecodeError(document []byte, de *decodeError) *DecodeError {
buf.WriteString(strings.Repeat(" ", len(before[0])))
}
- buf.WriteString(strings.Repeat("~", len(de.highlight)))
+ buf.WriteString(strings.Repeat("~", len(de.Highlight)))
if len(errMessage) > 0 {
buf.WriteString(" ")
@@ -183,7 +165,7 @@ func wrapDecodeError(document []byte, de *decodeError) *DecodeError {
message: errMessage,
line: errLine,
column: errColumn,
- key: de.key,
+ key: de.Key,
human: buf.String(),
}
}