"use strict";
/**
 * Copyright: (c) Myia SAS 2026.
 * This file and its contents are licensed under the AGPLv3 License.
 * Please see the LICENSE file at the root of this repository
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildThrowEvent = buildThrowEvent;
const error_serializer_1 = require("../serializers/error-serializer");
function buildThrowEvent(state, err) {
    const enter = state.enterStack.pop();
    const n = state.clock.now() - state.startedAt;
    const event = {
        type: 'throw',
        seq: ++state.seq,
        enterSeq: enter ? enter.seq : null,
        t: n,
        wallTime: Date.now(),
        duration: enter ? n - enter.t : 0,
        error: (0, error_serializer_1.serializeError)(err),
    };
    state.exporter.write(event);
}
