File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 11package golangsdk
22
3- import "fmt"
3+ import (
4+ "fmt"
5+ "strings"
6+ )
47
58// BaseError is an error type that all other error types embed.
69type BaseError struct {
@@ -118,9 +121,21 @@ func (e ErrDefault401) Error() string {
118121 return "Authentication failed"
119122}
120123func (e ErrDefault403 ) Error () string {
124+ var maxLength int = 200
125+ var unAuthorized string = "Request not authorized"
126+
127+ messageBody := string (e .Body )
128+ if len (messageBody ) > maxLength {
129+ if strings .Contains (messageBody , unAuthorized ) {
130+ messageBody = unAuthorized
131+ } else {
132+ messageBody = messageBody [:maxLength ] + "\n ..."
133+ }
134+ }
135+
121136 e .DefaultErrString = fmt .Sprintf (
122137 "Action forbidden: [%s %s], error message: %s" ,
123- e .Method , e .URL , e . Body ,
138+ e .Method , e .URL , messageBody ,
124139 )
125140 return e .choseErrString ()
126141}
You can’t perform that action at this time.
0 commit comments