From 1dba94311aeec698cfbfb2ad825d5e1a4cd9d927 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Fri, 5 Jun 2020 10:43:23 -0400 Subject: [PATCH] Add helper for generating better permission denied errors --- acl/errors.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/acl/errors.go b/acl/errors.go index 65c5cc7ab6..2bb05c859b 100644 --- a/acl/errors.go +++ b/acl/errors.go @@ -2,6 +2,7 @@ package acl import ( "errors" + "fmt" "strings" ) @@ -70,3 +71,8 @@ func (e PermissionDeniedError) Error() string { } return errPermissionDenied } + +func PermissionDenied(msg string, args ...interface{}) PermissionDeniedError { + cause := fmt.Sprintf(msg, args...) + return PermissionDeniedError{Cause: cause} +}