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:
@@ -30,10 +30,10 @@
|
||||
package etcd
|
||||
|
||||
import (
|
||||
"github.com/purpleidea/mgmt/etcd/interfaces"
|
||||
"github.com/purpleidea/mgmt/util"
|
||||
)
|
||||
|
||||
const (
|
||||
// errInconsistentApply means applyDeltaEvents wasn't consistent.
|
||||
errInconsistentApply = interfaces.Error("inconsistent apply")
|
||||
errInconsistentApply = util.Error("inconsistent apply")
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
|
||||
36
util/error.go
Normal file
36
util/error.go
Normal file
@@ -0,0 +1,36 @@
|
||||
// Mgmt
|
||||
// Copyright (C) James Shubin and the project contributors
|
||||
// Written by James Shubin <james@shubin.ca> and the project contributors
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
//
|
||||
// Additional permission under GNU GPL version 3 section 7
|
||||
//
|
||||
// If you modify this program, or any covered work, by linking or combining it
|
||||
// with embedded mcl code and modules (and that the embedded mcl code and
|
||||
// modules which link with this program, contain a copy of their source code in
|
||||
// the authoritative form) containing parts covered by the terms of any other
|
||||
// license, the licensors of this program grant you additional permission to
|
||||
// convey the resulting work. Furthermore, the licensors of this program grant
|
||||
// the original author, James Shubin, additional permission to update this
|
||||
// additional permission if he deems it necessary to achieve the goals of this
|
||||
// additional permission.
|
||||
|
||||
package util
|
||||
|
||||
// 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) }
|
||||
Reference in New Issue
Block a user