server_error.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Licensed under the Apache License, Version 2.0 (the "License");
  3. * you may not use this file except in compliance with the License.
  4. * You may obtain a copy of the License at
  5. *
  6. * http://www.apache.org/licenses/LICENSE-2.0
  7. *
  8. * Unless required by applicable law or agreed to in writing, software
  9. * distributed under the License is distributed on an "AS IS" BASIS,
  10. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. * See the License for the specific language governing permissions and
  12. * limitations under the License.
  13. */
  14. package errors
  15. import "fmt"
  16. type ServerError struct {
  17. httpStatus int
  18. errorCode string
  19. message string
  20. }
  21. func NewServerError(httpStatus int, errorCode, message string) Error {
  22. return &ServerError{
  23. httpStatus: httpStatus,
  24. errorCode: errorCode,
  25. message: message,
  26. }
  27. }
  28. func (err *ServerError) HttpStatus() int {
  29. return err.httpStatus
  30. }
  31. func (err *ServerError) ErrorCode() string {
  32. return err.errorCode
  33. }
  34. func (err *ServerError) Message() string {
  35. return err.message
  36. }
  37. func (err *ServerError) Error() string {
  38. return fmt.Sprintf("SDK.ServerError %s %s", err.errorCode, err.message)
  39. }
  40. func (err *ServerError) OriginError() error {
  41. return nil
  42. }