1// Copyright (c) 2015-2021 MinIO, Inc. 2// 3// This file is part of MinIO Object Storage stack 4// 5// This program is free software: you can redistribute it and/or modify 6// it under the terms of the GNU Affero General Public License as published by 7// the Free Software Foundation, either version 3 of the License, or 8// (at your option) any later version. 9// 10// This program is distributed in the hope that it will be useful 11// but WITHOUT ANY WARRANTY; without even the implied warranty of 12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13// GNU Affero General Public License for more details. 14// 15// You should have received a copy of the GNU Affero General Public License 16// along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18package policy 19 20import ( 21 "fmt" 22) 23 24// Error is the generic type for any error happening during policy 25// parsing. 26type Error struct { 27 err error 28} 29 30// Errorf - formats according to a format specifier and returns 31// the string as a value that satisfies error of type policy.Error 32func Errorf(format string, a ...interface{}) error { 33 return Error{err: fmt.Errorf(format, a...)} 34} 35 36// Unwrap the internal error. 37func (e Error) Unwrap() error { return e.err } 38 39// Error 'error' compatible method. 40func (e Error) Error() string { 41 if e.err == nil { 42 return "policy: cause <nil>" 43 } 44 return e.err.Error() 45} 46