"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.serializeResult = serializeResult;
/**
 * Converts a Result object to a JSON-serializable form.
 * Error objects have non-enumerable properties, so JSON.stringify produces `{}`.
 * This replaces the `error` field with the error message string.
 */
function serializeResult(result) {
    if (!result.success) {
        const { error, ...rest } = result;
        return { ...rest, error: error.message };
    }
    return result;
}
//# sourceMappingURL=result.js.map