frostfs-node/pkg/services/object/get/v2/errors.go
Evgenii Stratonikov 0924b62a95 [#1083] objsvc/v2: Unify response verification after forwarding
1. Use the same routine for HEAD/GET_RANGE methods.
2. Make error message similar.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2024-05-15 12:04:06 +03:00

88 lines
2.6 KiB
Go

package getsvc
import (
"errors"
"fmt"
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object"
refs "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs"
)
var (
errMissingObjAddress = errors.New("missing object address")
errWrongMessageSeq = errors.New("incorrect message sequence")
errNilObjectPart = errors.New("nil object part")
errMissingSignature = errors.New("missing signature")
errInvalidObjectIDSign = errors.New("invalid object ID signature")
errWrongHeaderPartTypeExpShortRecvWithSignature = fmt.Errorf("wrong header part type: expected %T, received %T",
(*objectV2.ShortHeader)(nil), (*objectV2.HeaderWithSignature)(nil),
)
errWrongHeaderPartTypeExpWithSignRecvShort = fmt.Errorf("wrong header part type: expected %T, received %T",
(*objectV2.HeaderWithSignature)(nil), (*objectV2.ShortHeader)(nil),
)
)
func errInvalidObjAddress(err error) error {
return fmt.Errorf("invalid object address: %w", err)
}
func errRequestParamsValidation(err error) error {
return fmt.Errorf("request params validation: %w", err)
}
func errFetchingSessionKey(err error) error {
return fmt.Errorf("fetching session key: %w", err)
}
func errUnknownChechsumType(t refs.ChecksumType) error {
return fmt.Errorf("unknown checksum type %v", t)
}
func errResponseVerificationFailed(err error) error {
return fmt.Errorf("response verification failed: %w", err)
}
func errCouldNotWriteObjHeader(err error) error {
return fmt.Errorf("could not write object header in Get forwarder: %w", err)
}
func errStreamOpenningFailed(err error) error {
return fmt.Errorf("stream opening failed: %w", err)
}
func errReadingResponseFailed(err error) error {
return fmt.Errorf("reading the response failed: %w", err)
}
func errUnexpectedObjectPart(v objectV2.GetObjectPart) error {
return fmt.Errorf("unexpected object part %T", v)
}
func errCouldNotWriteObjChunk(forwarder string, err error) error {
return fmt.Errorf("could not write object chunk in %s forwarder: %w", forwarder, err)
}
func errCouldNotCreateGetRangeStream(err error) error {
return fmt.Errorf("could not create Get payload range stream: %w", err)
}
func errUnexpectedRangePart(v objectV2.GetRangePart) error {
return fmt.Errorf("unexpected range type %T", v)
}
func errUnexpectedHeaderPart(v objectV2.GetHeaderPart) error {
return fmt.Errorf("unexpected header type %T", v)
}
func errMarshalID(err error) error {
return fmt.Errorf("marshal ID: %w", err)
}
func errCantReadSignature(err error) error {
return fmt.Errorf("can't read signature: %w", err)
}
func errSendingRequestFailed(err error) error {
return fmt.Errorf("sending the request failed: %w", err)
}