2022-02-28 10:19:54 +00:00
|
|
|
package apistatus
|
|
|
|
|
|
|
|
import (
|
2022-12-13 14:36:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/session"
|
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/status"
|
2022-02-28 10:19:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// SessionTokenNotFound describes status of the failure because of the missing session token.
|
|
|
|
// Instances provide Status and StatusV2 interfaces.
|
|
|
|
type SessionTokenNotFound struct {
|
|
|
|
v2 status.Status
|
|
|
|
}
|
|
|
|
|
2022-12-08 16:34:52 +00:00
|
|
|
const defaultSessionTokenNotFoundMsg = "session token not found"
|
|
|
|
|
2022-02-28 10:19:54 +00:00
|
|
|
func (x SessionTokenNotFound) Error() string {
|
2022-12-08 16:34:52 +00:00
|
|
|
msg := x.v2.Message()
|
|
|
|
if msg == "" {
|
|
|
|
msg = defaultSessionTokenNotFoundMsg
|
|
|
|
}
|
|
|
|
|
2022-02-28 10:19:54 +00:00
|
|
|
return errMessageStatusV2(
|
|
|
|
globalizeCodeV2(session.StatusTokenNotFound, session.GlobalizeFail),
|
2022-12-08 16:34:52 +00:00
|
|
|
msg,
|
2022-02-28 10:19:54 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// implements local interface defined in FromStatusV2 func.
|
|
|
|
func (x *SessionTokenNotFound) fromStatusV2(st *status.Status) {
|
|
|
|
x.v2 = *st
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToStatusV2 implements StatusV2 interface method.
|
|
|
|
// If the value was returned by FromStatusV2, returns the source message.
|
|
|
|
// Otherwise, returns message with
|
2022-08-24 14:17:40 +00:00
|
|
|
// - code: TOKEN_NOT_FOUND;
|
|
|
|
// - string message: "session token not found";
|
|
|
|
// - details: empty.
|
2022-02-28 10:19:54 +00:00
|
|
|
func (x SessionTokenNotFound) ToStatusV2() *status.Status {
|
|
|
|
x.v2.SetCode(globalizeCodeV2(session.StatusTokenNotFound, session.GlobalizeFail))
|
2022-12-08 16:34:52 +00:00
|
|
|
x.v2.SetMessage(defaultSessionTokenNotFoundMsg)
|
2022-02-28 10:19:54 +00:00
|
|
|
return &x.v2
|
|
|
|
}
|
|
|
|
|
|
|
|
// SessionTokenExpired describes status of the failure because of the expired session token.
|
|
|
|
// Instances provide Status and StatusV2 interfaces.
|
|
|
|
type SessionTokenExpired struct {
|
|
|
|
v2 status.Status
|
|
|
|
}
|
|
|
|
|
2022-12-08 16:34:52 +00:00
|
|
|
const defaultSessionTokenExpiredMsg = "expired session token"
|
|
|
|
|
2022-02-28 10:19:54 +00:00
|
|
|
func (x SessionTokenExpired) Error() string {
|
2022-12-08 16:34:52 +00:00
|
|
|
msg := x.v2.Message()
|
|
|
|
if msg == "" {
|
|
|
|
msg = defaultSessionTokenExpiredMsg
|
|
|
|
}
|
|
|
|
|
2022-02-28 10:19:54 +00:00
|
|
|
return errMessageStatusV2(
|
|
|
|
globalizeCodeV2(session.StatusTokenExpired, session.GlobalizeFail),
|
2022-12-08 16:34:52 +00:00
|
|
|
msg,
|
2022-02-28 10:19:54 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// implements local interface defined in FromStatusV2 func.
|
|
|
|
func (x *SessionTokenExpired) fromStatusV2(st *status.Status) {
|
|
|
|
x.v2 = *st
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToStatusV2 implements StatusV2 interface method.
|
|
|
|
// If the value was returned by FromStatusV2, returns the source message.
|
|
|
|
// Otherwise, returns message with
|
2022-08-24 14:17:40 +00:00
|
|
|
// - code: TOKEN_EXPIRED;
|
|
|
|
// - string message: "expired session token";
|
|
|
|
// - details: empty.
|
2022-02-28 10:19:54 +00:00
|
|
|
func (x SessionTokenExpired) ToStatusV2() *status.Status {
|
|
|
|
x.v2.SetCode(globalizeCodeV2(session.StatusTokenExpired, session.GlobalizeFail))
|
2022-12-08 16:34:52 +00:00
|
|
|
x.v2.SetMessage(defaultSessionTokenExpiredMsg)
|
2022-02-28 10:19:54 +00:00
|
|
|
return &x.v2
|
|
|
|
}
|