2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-02-25 06:48:14 +11:00
|
|
|
import { DiagnosticItem } from "./diagnostics.ts";
|
2019-09-02 17:07:11 -04:00
|
|
|
import * as dispatch from "./dispatch.ts";
|
|
|
|
import { sendSync } from "./dispatch_json.ts";
|
2019-02-09 13:55:40 -08:00
|
|
|
|
2019-08-26 14:50:21 +02:00
|
|
|
// TODO(bartlomieju): move to `repl.ts`?
|
2019-02-09 13:55:40 -08:00
|
|
|
export function formatError(errString: string): string {
|
2019-08-26 14:50:21 +02:00
|
|
|
const res = sendSync(dispatch.OP_FORMAT_ERROR, { error: errString });
|
|
|
|
return res.error;
|
2019-02-09 13:55:40 -08:00
|
|
|
}
|
2020-02-25 06:48:14 +11:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Format an array of diagnostic items and return them as a single string.
|
|
|
|
* @param items An array of diagnostic items to format
|
|
|
|
*/
|
|
|
|
export function formatDiagnostics(items: DiagnosticItem[]): string {
|
|
|
|
return sendSync(dispatch.OP_FORMAT_DIAGNOSTIC, { items });
|
|
|
|
}
|