Extract rpc server wrapped errors and translate to storage error.

This commit is contained in:
Harshavardhana 2016-08-11 15:55:36 -07:00
parent cae5761f16
commit 6908a0dcd4

View File

@ -18,6 +18,7 @@ package main
import (
"errors"
"io"
"net/rpc"
"path"
"strconv"
@ -49,6 +50,12 @@ func splitNetPath(networkPath string) (netAddr, netPath string) {
// disks as well.
func toStorageErr(err error) error {
switch err.Error() {
case io.EOF.Error():
return io.EOF
case io.ErrUnexpectedEOF.Error():
return io.ErrUnexpectedEOF
case errUnexpected.Error():
return errUnexpected
case errDiskFull.Error():
return errDiskFull
case errVolumeNotFound.Error():
@ -57,14 +64,20 @@ func toStorageErr(err error) error {
return errVolumeExists
case errFileNotFound.Error():
return errFileNotFound
case errFileNameTooLong.Error():
return errFileNameTooLong
case errFileAccessDenied.Error():
return errFileAccessDenied
case errIsNotRegular.Error():
return errIsNotRegular
case errVolumeNotEmpty.Error():
return errVolumeNotEmpty
case errFileAccessDenied.Error():
return errFileAccessDenied
case errVolumeAccessDenied.Error():
return errVolumeAccessDenied
case errCorruptedFormat.Error():
return errCorruptedFormat
case errUnformattedDisk.Error():
return errUnformattedDisk
}
return err
}