Skip to content

Commit

Permalink
json encode storage driver enclosed error (#4099)
Browse files Browse the repository at this point in the history
  • Loading branch information
milosgajdos committed Oct 17, 2023
2 parents 1d41014 + fee6fae commit 915ad2d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions registry/storage/driver/storagedriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package driver

import (
"context"
"encoding/json"
"fmt"
"io"
"regexp"
Expand Down Expand Up @@ -184,6 +185,16 @@ func (err Error) Error() string {
return fmt.Sprintf("%s: %s", err.DriverName, err.Enclosed)
}

func (err Error) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
DriverName string `json:"driver"`
Enclosed string `json:"enclosed"`
}{
DriverName: err.DriverName,
Enclosed: err.Enclosed.Error(),
})
}

// Errors provides the envelope for multiple errors
// for use within the storagedriver implementations.
type Errors struct {
Expand Down

0 comments on commit 915ad2d

Please sign in to comment.