mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
24 lines
346 B
Go
24 lines
346 B
Go
package gotsrpc
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
type HTTPError struct {
|
|
StatusCode int
|
|
Body string
|
|
error
|
|
}
|
|
|
|
func NewHTTPError(msg string, code int) *HTTPError {
|
|
return &HTTPError{
|
|
error: errors.New(msg),
|
|
StatusCode: code,
|
|
}
|
|
}
|
|
|
|
func (e *HTTPError) Error() string {
|
|
return fmt.Sprintf("[%d] %s", e.StatusCode, e.error.Error())
|
|
}
|