package commerce

import "fmt"

type HTTPError struct {
	Status int
	Detail any
}

func (e HTTPError) Error() string {
	return fmt.Sprint(e.Detail)
}

func NotFound(detail any) HTTPError {
	return HTTPError{Status: 404, Detail: detail}
}

func BadRequest(detail any) HTTPError {
	return HTTPError{Status: 400, Detail: detail}
}

func Unauthorized(detail any) HTTPError {
	return HTTPError{Status: 401, Detail: detail}
}

func Conflict(detail any) HTTPError {
	return HTTPError{Status: 409, Detail: detail}
}

func ServiceUnavailable(detail any) HTTPError {
	return HTTPError{Status: 503, Detail: detail}
}

func BadGateway(detail any) HTTPError {
	return HTTPError{Status: 502, Detail: detail}
}
