forked from TrueCloudLab/distribution
json encode storage driver enclosed error (#4099)
This commit is contained in:
commit
915ad2d5a6
1 changed files with 11 additions and 0 deletions
|
@ -2,6 +2,7 @@ package driver
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue