import type { DebuggingService } from '../services/debugging.service';

export function reportDebuggingError(
  debugging: DebuggingService,
  source: string,
  message: string,
  payload: Record<string, unknown>,
  error: unknown
): void {
  debugging.error(source, message, {
    ...payload,
    error
  });
}

export function trackDebuggingTaskFailure(
  task: Promise<unknown> | unknown,
  debugging: DebuggingService,
  source: string,
  message: string,
  payload: Record<string, unknown>
): void {
  Promise.resolve(task).catch((error) => {
    reportDebuggingError(debugging, source, message, payload, error);
  });
}
