package utils

import "encoding/json"

type V1beta1Error struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Details []any  `json:"details,omitempty"`
}

func (e *V1beta1Error) Marshal() ([]byte, error) {
	b, err := json.Marshal(e)
	if err != nil {
		return nil, err
	}
	return b, nil
}

type V1betaError struct {
	Error *ErrorDetail `json:"error,omitempty"`
}

type ErrorDetail struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Details []any  `json:"details,omitempty"`
}

func (e *V1betaError) Marshal() ([]byte, error) {
	b, err := json.Marshal(e)
	if err != nil {
		return nil, err
	}
	return b, nil
}
