mirror of
https://github.com/minio/minio.git
synced 2025-11-26 04:26:12 -05:00
Add more context aware error for policy parsing errors (#8726)
In existing functionality we simply return a generic error such as "MalformedPolicy" which indicates just a generic string "invalid resource" which is not very meaningful when there might be multiple types of errors during policy parsing. This PR ensures that we send these errors back to client to indicate the actual error, brings in two concrete types such as - iampolicy.Error - policy.Error Refer #8202
This commit is contained in:
@@ -69,7 +69,7 @@ func (resourceSet ResourceSet) Intersection(sset ResourceSet) ResourceSet {
|
||||
// MarshalJSON - encodes ResourceSet to JSON data.
|
||||
func (resourceSet ResourceSet) MarshalJSON() ([]byte, error) {
|
||||
if len(resourceSet) == 0 {
|
||||
return nil, fmt.Errorf("empty resource set")
|
||||
return nil, Errorf("empty resource set")
|
||||
}
|
||||
|
||||
resources := []Resource{}
|
||||
@@ -116,7 +116,7 @@ func (resourceSet *ResourceSet) UnmarshalJSON(data []byte) error {
|
||||
}
|
||||
|
||||
if _, found := (*resourceSet)[resource]; found {
|
||||
return fmt.Errorf("duplicate resource '%v' found", s)
|
||||
return Errorf("duplicate resource '%v' found", s)
|
||||
}
|
||||
|
||||
resourceSet.Add(resource)
|
||||
|
||||
Reference in New Issue
Block a user