2021-04-18 15:41:13 -04:00
|
|
|
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2020-01-03 14:28:52 -05:00
|
|
|
|
|
|
|
package iampolicy
|
|
|
|
|
2020-01-07 12:13:44 -05:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
2020-01-03 14:28:52 -05:00
|
|
|
|
2020-01-06 19:15:22 -05:00
|
|
|
// Error is the generic type for any error happening during policy
|
|
|
|
// parsing.
|
2020-01-03 14:28:52 -05:00
|
|
|
type Error struct {
|
2020-01-06 19:15:22 -05:00
|
|
|
err error
|
2020-01-03 14:28:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Errorf - formats according to a format specifier and returns
|
2020-01-06 19:15:22 -05:00
|
|
|
// the string as a value that satisfies error of type policy.Error
|
2020-01-03 14:28:52 -05:00
|
|
|
func Errorf(format string, a ...interface{}) error {
|
2020-01-06 19:15:22 -05:00
|
|
|
return Error{err: fmt.Errorf(format, a...)}
|
2020-01-03 14:28:52 -05:00
|
|
|
}
|
|
|
|
|
2020-01-06 19:15:22 -05:00
|
|
|
// Unwrap the internal error.
|
|
|
|
func (e Error) Unwrap() error { return e.err }
|
2020-01-03 14:28:52 -05:00
|
|
|
|
2020-01-06 19:15:22 -05:00
|
|
|
// Error 'error' compatible method.
|
2020-01-03 14:28:52 -05:00
|
|
|
func (e Error) Error() string {
|
2020-01-06 19:15:22 -05:00
|
|
|
if e.err == nil {
|
|
|
|
return "iam: cause <nil>"
|
|
|
|
}
|
|
|
|
return e.err.Error()
|
2020-01-03 14:28:52 -05:00
|
|
|
}
|