github.com/weaviate/weaviate@v1.24.6/entities/errors/errors_remote_client.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  package errors
    13  
    14  import (
    15  	"fmt"
    16  )
    17  
    18  type ErrOpenHttpRequest struct {
    19  	err error
    20  }
    21  
    22  func (e ErrOpenHttpRequest) Error() string {
    23  	return e.err.Error()
    24  }
    25  
    26  func NewErrOpenHttpRequest(err error) ErrOpenHttpRequest {
    27  	return ErrOpenHttpRequest{fmt.Errorf("open http request: %w", err)}
    28  }
    29  
    30  type ErrSendHttpRequest struct {
    31  	err error
    32  }
    33  
    34  func (e ErrSendHttpRequest) Error() string {
    35  	return e.err.Error()
    36  }
    37  
    38  // Unwrap returns the original inner error, so it can be
    39  // used with errors.Is and errors.As
    40  func (e ErrSendHttpRequest) Unwrap() error {
    41  	return e.err
    42  }
    43  
    44  func NewErrSendHttpRequest(err error) ErrSendHttpRequest {
    45  	return ErrSendHttpRequest{fmt.Errorf("send http request: %w", err)}
    46  }
    47  
    48  type ErrUnexpectedStatusCode struct {
    49  	err error
    50  }
    51  
    52  func (e ErrUnexpectedStatusCode) Error() string {
    53  	return e.err.Error()
    54  }
    55  
    56  func NewErrUnexpectedStatusCode(statusCode int, body []byte) ErrUnexpectedStatusCode {
    57  	return ErrUnexpectedStatusCode{
    58  		err: fmt.Errorf("unexpected status code %d (%s)", statusCode, body),
    59  	}
    60  }
    61  
    62  type ErrUnmarshalBody struct {
    63  	err error
    64  }
    65  
    66  func (e ErrUnmarshalBody) Error() string {
    67  	return e.err.Error()
    68  }
    69  
    70  func NewErrUnmarshalBody(err error) ErrUnmarshalBody {
    71  	return ErrUnmarshalBody{fmt.Errorf("unmarshal body: %w", err)}
    72  }