File: response.go

package info (click to toggle)
golang-github-aws-smithy-go 1.13.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,228 kB
  • sloc: java: 12,359; xml: 166; sh: 131; makefile: 47
file content (34 lines) | stat: -rw-r--r-- 977 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package http

import (
	"fmt"
	"net/http"
)

// Response provides the HTTP specific response structure for HTTP specific
// middleware steps to use to deserialize the response from an operation call.
type Response struct {
	*http.Response
}

// ResponseError provides the HTTP centric error type wrapping the underlying
// error with the HTTP response value.
type ResponseError struct {
	Response *Response
	Err      error
}

// HTTPStatusCode returns the HTTP response status code received from the service.
func (e *ResponseError) HTTPStatusCode() int { return e.Response.StatusCode }

// HTTPResponse returns the HTTP response received from the service.
func (e *ResponseError) HTTPResponse() *Response { return e.Response }

// Unwrap returns the nested error if any, or nil.
func (e *ResponseError) Unwrap() error { return e.Err }

func (e *ResponseError) Error() string {
	return fmt.Sprintf(
		"http response error StatusCode: %d, %v",
		e.Response.StatusCode, e.Err)
}