git.frostfs.info/TrueCloudLab/frostfs-sdk-go@v0.0.0-20241022124111-5361f0ecebd3/client/status/session.go (about) 1 package apistatus 2 3 import ( 4 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session" 5 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/status" 6 ) 7 8 // SessionTokenNotFound describes status of the failure because of the missing session token. 9 // Instances provide Status and StatusV2 interfaces. 10 type SessionTokenNotFound struct { 11 v2 status.Status 12 } 13 14 const defaultSessionTokenNotFoundMsg = "session token not found" 15 16 func (x *SessionTokenNotFound) Error() string { 17 msg := x.v2.Message() 18 if msg == "" { 19 msg = defaultSessionTokenNotFoundMsg 20 } 21 22 return errMessageStatusV2( 23 globalizeCodeV2(session.StatusTokenNotFound, session.GlobalizeFail), 24 msg, 25 ) 26 } 27 28 // implements local interface defined in FromStatusV2 func. 29 func (x *SessionTokenNotFound) fromStatusV2(st *status.Status) { 30 x.v2 = *st 31 } 32 33 // ToStatusV2 implements StatusV2 interface method. 34 // If the value was returned by FromStatusV2, returns the source message. 35 // Otherwise, returns message with 36 // - code: TOKEN_NOT_FOUND; 37 // - string message: "session token not found"; 38 // - details: empty. 39 func (x SessionTokenNotFound) ToStatusV2() *status.Status { 40 x.v2.SetCode(globalizeCodeV2(session.StatusTokenNotFound, session.GlobalizeFail)) 41 x.v2.SetMessage(defaultSessionTokenNotFoundMsg) 42 return &x.v2 43 } 44 45 // SessionTokenExpired describes status of the failure because of the expired session token. 46 // Instances provide Status and StatusV2 interfaces. 47 type SessionTokenExpired struct { 48 v2 status.Status 49 } 50 51 const defaultSessionTokenExpiredMsg = "expired session token" 52 53 func (x *SessionTokenExpired) Error() string { 54 msg := x.v2.Message() 55 if msg == "" { 56 msg = defaultSessionTokenExpiredMsg 57 } 58 59 return errMessageStatusV2( 60 globalizeCodeV2(session.StatusTokenExpired, session.GlobalizeFail), 61 msg, 62 ) 63 } 64 65 // implements local interface defined in FromStatusV2 func. 66 func (x *SessionTokenExpired) fromStatusV2(st *status.Status) { 67 x.v2 = *st 68 } 69 70 // ToStatusV2 implements StatusV2 interface method. 71 // If the value was returned by FromStatusV2, returns the source message. 72 // Otherwise, returns message with 73 // - code: TOKEN_EXPIRED; 74 // - string message: "expired session token"; 75 // - details: empty. 76 func (x SessionTokenExpired) ToStatusV2() *status.Status { 77 x.v2.SetCode(globalizeCodeV2(session.StatusTokenExpired, session.GlobalizeFail)) 78 x.v2.SetMessage(defaultSessionTokenExpiredMsg) 79 return &x.v2 80 }