summaryrefslogtreecommitdiff
path: root/cli/js/ops/errors.ts
blob: c6c26b8ba69d1b2b59270a0e2fa33177994a8ab5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { DiagnosticItem } from "../diagnostics.ts";
import { sendSync } from "./dispatch_json.ts";

export function formatDiagnostics(items: DiagnosticItem[]): string {
  return sendSync("op_format_diagnostic", { items });
}

export interface Location {
  fileName: string;
  lineNumber: number;
  columnNumber: number;
}

export function applySourceMap(location: Location): Location {
  const res = sendSync("op_apply_source_map", location);
  return {
    fileName: res.fileName,
    lineNumber: res.lineNumber,
    columnNumber: res.columnNumber,
  };
}