2011-01-11 20:54:30 -05:00
|
|
|
// Copyright 2010 The Go Authors. All rights reserved.
|
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
2011-04-20 09:57:05 +10:00
|
|
|
// Package error contains common error types for the OpenPGP packages.
|
2011-01-11 20:54:30 -05:00
|
|
|
package error
|
|
|
|
|
|
2011-02-11 08:34:19 -05:00
|
|
|
import (
|
|
|
|
|
"strconv"
|
|
|
|
|
)
|
|
|
|
|
|
2011-01-11 20:54:30 -05:00
|
|
|
// A StructuralError is returned when OpenPGP data is found to be syntactically
|
|
|
|
|
// invalid.
|
|
|
|
|
type StructuralError string
|
|
|
|
|
|
|
|
|
|
func (s StructuralError) String() string {
|
|
|
|
|
return "OpenPGP data invalid: " + string(s)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UnsupportedError indicates that, although the OpenPGP data is valid, it
|
|
|
|
|
// makes use of currently unimplemented features.
|
|
|
|
|
type UnsupportedError string
|
|
|
|
|
|
|
|
|
|
func (s UnsupportedError) String() string {
|
|
|
|
|
return "OpenPGP feature unsupported: " + string(s)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// InvalidArgumentError indicates that the caller is in error and passed an
|
|
|
|
|
// incorrect value.
|
|
|
|
|
type InvalidArgumentError string
|
|
|
|
|
|
|
|
|
|
func (i InvalidArgumentError) String() string {
|
|
|
|
|
return "OpenPGP argument invalid: " + string(i)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SignatureError indicates that a syntactically valid signature failed to
|
|
|
|
|
// validate.
|
|
|
|
|
type SignatureError string
|
|
|
|
|
|
|
|
|
|
func (b SignatureError) String() string {
|
|
|
|
|
return "OpenPGP signature invalid: " + string(b)
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-27 19:38:32 -07:00
|
|
|
type keyIncorrectError int
|
2011-01-11 20:54:30 -05:00
|
|
|
|
2011-10-27 19:38:32 -07:00
|
|
|
func (ki keyIncorrectError) String() string {
|
2011-01-11 20:54:30 -05:00
|
|
|
return "the given key was incorrect"
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-27 19:38:32 -07:00
|
|
|
var KeyIncorrectError = keyIncorrectError(0)
|
2011-02-11 08:34:19 -05:00
|
|
|
|
2011-10-27 19:38:32 -07:00
|
|
|
type unknownIssuerError int
|
2011-02-11 08:34:19 -05:00
|
|
|
|
2011-10-27 19:38:32 -07:00
|
|
|
func (unknownIssuerError) String() string {
|
2011-02-11 08:34:19 -05:00
|
|
|
return "signature make by unknown entity"
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-27 19:38:32 -07:00
|
|
|
var UnknownIssuerError = unknownIssuerError(0)
|
2011-02-11 08:34:19 -05:00
|
|
|
|
|
|
|
|
type UnknownPacketTypeError uint8
|
|
|
|
|
|
|
|
|
|
func (upte UnknownPacketTypeError) String() string {
|
|
|
|
|
return "unknown OpenPGP packet type: " + strconv.Itoa(int(upte))
|
|
|
|
|
}
|