refactor: Use simpler error messages
This commit is contained in:
+22
-19
@@ -3,30 +3,33 @@ package config
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
ErrEncryptionFormatUnknown = errors.New("unknown encryption format")
|
||||
ErrEncryptionFormatUnsupported = errors.New("unsupported encryption format")
|
||||
ErrEncryptionFormatUnknown = errors.New("encryption format unknown")
|
||||
ErrSignatureFormatUnknown = errors.New("signature format unknown")
|
||||
ErrCompressionFormatUnknown = errors.New("compression format unknown")
|
||||
|
||||
ErrEncryptionFormatUnsupported = errors.New("encryption format unsupported")
|
||||
ErrSignatureFormatUnsupported = errors.New("signature format unsupported")
|
||||
ErrCompressionFormatUnsupported = errors.New("compression format unsupported")
|
||||
|
||||
ErrSignatureFormatRegularOnly = errors.New("signature format only supports regular files, not tape drives")
|
||||
ErrSignatureInvalid = errors.New("signature invalid")
|
||||
ErrSignatureMissing = errors.New("signature missing")
|
||||
|
||||
ErrCompressionFormatRegularOnly = errors.New("compression format only supports regular files, not tape drives")
|
||||
ErrCompressionFormatRequiresLargerRecordSize = errors.New("compression format requires larger record size")
|
||||
ErrCompressionLevelUnsupported = errors.New("compression level unsupported")
|
||||
ErrCompressionLevelUnknown = errors.New("compression level unknown")
|
||||
|
||||
ErrIdentityUnparsable = errors.New("identity could not be parsed")
|
||||
ErrRecipientUnparsable = errors.New("recipient could not be parsed")
|
||||
|
||||
ErrEmbeddedHeaderMissing = errors.New("embedded header is missing")
|
||||
ErrKeygenFormatUnsupported = errors.New("key generation for format unsupported")
|
||||
|
||||
ErrSignatureFormatUnknown = errors.New("unknown signature format")
|
||||
ErrSignatureFormatUnsupported = errors.New("unsupported signature format")
|
||||
ErrSignatureFormatOnlyRegularSupport = errors.New("this signature format only supports regular files, not i.e. tape drives")
|
||||
ErrSignatureInvalid = errors.New("signature is invalid")
|
||||
ErrSignatureMissing = errors.New("signature is missing")
|
||||
ErrTarHeaderMissing = errors.New("tar header missing")
|
||||
ErrTarHeaderEmbeddedMissing = errors.New("embedded tar header missing")
|
||||
|
||||
ErrKeygenForFormatUnsupported = errors.New("can not generate keys for this format")
|
||||
ErrTapeDrivesUnsupported = errors.New("system unsupported for tape drives")
|
||||
|
||||
ErrCompressionFormatUnknown = errors.New("unknown compression format")
|
||||
ErrCompressionFormatUnsupported = errors.New("unsupported compression format")
|
||||
ErrCompressionFormatOnlyRegularSupport = errors.New("this compression format only supports regular files, not i.e. tape drives")
|
||||
ErrCompressionFormatRequiresLargerRecordSize = errors.New("this compression format requires a larger record size")
|
||||
ErrCompressionLevelUnsupported = errors.New("compression level is unsupported")
|
||||
ErrCompressionLevelUnknown = errors.New("unknown compression level")
|
||||
|
||||
ErrMissingTarHeader = errors.New("tar header is missing")
|
||||
|
||||
ErrDrivesUnsupported = errors.New("this system does not support tape drives")
|
||||
ErrSTFSVersionUnsupported = errors.New("STFS version unsupported")
|
||||
ErrSTFSActionUnsupported = errors.New("STFS action unsupported")
|
||||
)
|
||||
|
||||
@@ -112,7 +112,7 @@ func Delete(
|
||||
}
|
||||
|
||||
if len(hdrs) <= i-1 {
|
||||
return config.ErrMissingTarHeader
|
||||
return config.ErrTarHeaderMissing
|
||||
}
|
||||
|
||||
*hdr = *hdrs[i-1]
|
||||
|
||||
@@ -116,7 +116,7 @@ func Move(
|
||||
}
|
||||
|
||||
if len(hdrs) <= i-1 {
|
||||
return config.ErrMissingTarHeader
|
||||
return config.ErrTarHeaderMissing
|
||||
}
|
||||
|
||||
*hdr = *hdrs[i-1]
|
||||
|
||||
@@ -360,10 +360,10 @@ func indexHeader(
|
||||
}
|
||||
|
||||
default:
|
||||
return records.ErrUnsupportedAction
|
||||
return config.ErrSTFSActionUnsupported
|
||||
}
|
||||
default:
|
||||
return records.ErrUnsupportedVersion
|
||||
return config.ErrSTFSVersionUnsupported
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -34,7 +34,7 @@ func Keygen(
|
||||
privkey = priv
|
||||
pubkey = pub
|
||||
} else {
|
||||
return []byte{}, []byte{}, config.ErrKeygenForFormatUnsupported
|
||||
return []byte{}, []byte{}, config.ErrKeygenFormatUnsupported
|
||||
}
|
||||
|
||||
return privkey, pubkey, nil
|
||||
@@ -106,7 +106,7 @@ func generateEncryptionKey(
|
||||
|
||||
return priv, pub, nil
|
||||
default:
|
||||
return []byte{}, []byte{}, config.ErrKeygenForFormatUnsupported
|
||||
return []byte{}, []byte{}, config.ErrKeygenFormatUnsupported
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,6 @@ func generateSignatureKey(
|
||||
case config.SignatureFormatPGPKey:
|
||||
return generateEncryptionKey(signatureFormat, password)
|
||||
default:
|
||||
return []byte{}, []byte{}, config.ErrKeygenForFormatUnsupported
|
||||
return []byte{}, []byte{}, config.ErrKeygenFormatUnsupported
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user