import { parseUrl } from '../url' ; import { HttpError } from './types' ; Object . defineProperty ( HttpError . prototype , 'statusCode' , { get : function statusCode ( this ) { return this . response ?. statusCode ; } , } ) ; Object . defineProperty ( HttpError . prototype , 'body' , { get : function body ( this ) : unknown { return this . response ?. body ; } , set : function body ( this , value ) : void { if ( this . response ) { this . response . body = value ; } } , } ) ; Object . defineProperty ( HttpError . prototype , 'headers' , { get : function headers ( this ) { return this . response ?. headers ; } , } ) ; Object . defineProperty ( HttpError . prototype , 'url' , { get : function url ( this ) { return this . response ?. url ; } , } ) ; Object . defineProperty ( HttpError . prototype , 'host' , { get : function url ( this ) { const urlStr = this . response ?. url ; const url = urlStr ? parseUrl ( urlStr ) : null ; return url ?. host ; } , } ) ; export type GotLegacyError < E = unknown , T = unknown > = HttpError & { statusCode ? : number ; body : { message ? : string ; errors ? : E [ ] ; } ; headers ? : Record < string , T > ; } ;