import { log } from '@mondaydotcomorg/atp-runtime';
/**
 * Handles HTTP request errors and sends appropriate responses
 */
export function handleError(res, error, requestId, additionalHeaders) {
    const status = error.status || 500;
    log.error('Request failed', { requestId, error: error.message, stack: error.stack });
    const headers = { 'Content-Type': 'application/json' };
    if (additionalHeaders) {
        for (const [key, value] of additionalHeaders.entries()) {
            headers[key] = value;
        }
    }
    res.writeHead(status, headers);
    res.end(JSON.stringify({ error: error.message, requestId }));
}
//# sourceMappingURL=error.js.map