util, lang, etcd: Move the error type to our util package
We use this error in a lot of places, let's centralize it a bit.
This commit is contained in:
@@ -160,16 +160,16 @@ const (
|
||||
scopedOrderingPrefix = "scoped:"
|
||||
|
||||
// ErrNoStoredScope is an error that tells us we can't get a scope here.
|
||||
ErrNoStoredScope = interfaces.Error("scope is not stored in this node")
|
||||
ErrNoStoredScope = util.Error("scope is not stored in this node")
|
||||
|
||||
// ErrFuncPointerNil is an error that explains the function pointer for
|
||||
// table lookup is missing. If this happens, it's most likely a
|
||||
// programming error.
|
||||
ErrFuncPointerNil = interfaces.Error("missing func pointer for table")
|
||||
ErrFuncPointerNil = util.Error("missing func pointer for table")
|
||||
|
||||
// ErrTableNoValue is an error that explains the table is missing a
|
||||
// value. If this happens, it's most likely a programming error.
|
||||
ErrTableNoValue = interfaces.Error("missing value in table")
|
||||
ErrTableNoValue = util.Error("missing value in table")
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -29,19 +29,17 @@
|
||||
|
||||
package interfaces
|
||||
|
||||
// Error is a constant error type that implements error.
|
||||
type Error string
|
||||
|
||||
// Error fulfills the error interface of this type.
|
||||
func (e Error) Error() string { return string(e) }
|
||||
import (
|
||||
"github.com/purpleidea/mgmt/util"
|
||||
)
|
||||
|
||||
const (
|
||||
// ErrTypeCurrentlyUnknown is returned from the Type() call on Expr if
|
||||
// unification didn't run successfully and the type isn't obvious yet.
|
||||
ErrTypeCurrentlyUnknown = Error("type is currently unknown")
|
||||
ErrTypeCurrentlyUnknown = util.Error("type is currently unknown")
|
||||
|
||||
// ErrExpectedFileMissing is returned when a file that is used by an
|
||||
// import is missing. This might signal the downloader, or it might
|
||||
// signal a permanent error.
|
||||
ErrExpectedFileMissing = Error("file is currently missing")
|
||||
ErrExpectedFileMissing = util.Error("file is currently missing")
|
||||
)
|
||||
|
||||
@@ -46,21 +46,21 @@ import (
|
||||
|
||||
// These constants represent the different possible lexer/parser errors.
|
||||
const (
|
||||
ErrLexerUnrecognized = interfaces.Error("unrecognized")
|
||||
ErrLexerUnrecognizedCR = interfaces.Error("unrecognized carriage return")
|
||||
ErrLexerStringBadEscaping = interfaces.Error("string: bad escaping")
|
||||
ErrLexerIntegerOverflow = interfaces.Error("integer: overflow")
|
||||
ErrLexerFloatOverflow = interfaces.Error("float: overflow")
|
||||
ErrParseError = interfaces.Error("parser")
|
||||
ErrParseSetType = interfaces.Error("can't set return type in parser")
|
||||
ErrParseResFieldInvalid = interfaces.Error("can't use unknown resource field")
|
||||
ErrParseAdditionalEquals = interfaces.Error(errstrParseAdditionalEquals)
|
||||
ErrParseExpectingComma = interfaces.Error(errstrParseExpectingComma)
|
||||
ErrLexerUnrecognized = util.Error("unrecognized")
|
||||
ErrLexerUnrecognizedCR = util.Error("unrecognized carriage return")
|
||||
ErrLexerStringBadEscaping = util.Error("string: bad escaping")
|
||||
ErrLexerIntegerOverflow = util.Error("integer: overflow")
|
||||
ErrLexerFloatOverflow = util.Error("float: overflow")
|
||||
ErrParseError = util.Error("parser")
|
||||
ErrParseSetType = util.Error("can't set return type in parser")
|
||||
ErrParseResFieldInvalid = util.Error("can't use unknown resource field")
|
||||
ErrParseAdditionalEquals = util.Error(errstrParseAdditionalEquals)
|
||||
ErrParseExpectingComma = util.Error(errstrParseExpectingComma)
|
||||
)
|
||||
|
||||
// LexParseErr is a permanent failure error to notify about borkage.
|
||||
type LexParseErr struct {
|
||||
Err interfaces.Error
|
||||
Err util.Error
|
||||
Str string
|
||||
Row int // this is zero-indexed (the first line is 0)
|
||||
Col int // this is zero-indexed (the first char is 0)
|
||||
|
||||
@@ -35,12 +35,13 @@ import (
|
||||
|
||||
"github.com/purpleidea/mgmt/lang/interfaces"
|
||||
"github.com/purpleidea/mgmt/lang/types"
|
||||
"github.com/purpleidea/mgmt/util"
|
||||
)
|
||||
|
||||
const (
|
||||
// ErrAmbiguous means we couldn't find a solution, but we weren't
|
||||
// inconsistent.
|
||||
ErrAmbiguous = interfaces.Error("can't unify, no equalities were consumed, we're ambiguous")
|
||||
ErrAmbiguous = util.Error("can't unify, no equalities were consumed, we're ambiguous")
|
||||
|
||||
// StrategyNameKey is the string key used when choosing a solver name.
|
||||
StrategyNameKey = "name"
|
||||
|
||||
Reference in New Issue
Block a user