server_error.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. type ServerError struct {
  16. httpStatus int
  17. errorCode string
  18. message string
  19. }
  20. func NewServerError(httpStatus int, errorCode, message string) Error {
  21. return &ServerError{
  22. httpStatus: httpStatus,
  23. errorCode: errorCode,
  24. message: message,
  25. }
  26. }
  27. func (err *ServerError) HttpStatus() int {
  28. return err.httpStatus
  29. }
  30. func (err *ServerError) ErrorCode() string {
  31. return err.errorCode
  32. }
  33. func (err *ServerError) Message() string {
  34. return err.message
  35. }
  36. func (err *ServerError) Error() string {
  37. return "SDK.ServerError"
  38. }
  39. func (err *ServerError) OriginError() error {
  40. return nil
  41. }