aboutsummaryrefslogtreecommitdiff
path: root/scripts/apidocs/processing/error.ts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/apidocs/processing/error.ts')
-rw-r--r--scripts/apidocs/processing/error.ts24
1 files changed, 14 insertions, 10 deletions
diff --git a/scripts/apidocs/processing/error.ts b/scripts/apidocs/processing/error.ts
index f171d6b4..e4117301 100644
--- a/scripts/apidocs/processing/error.ts
+++ b/scripts/apidocs/processing/error.ts
@@ -1,4 +1,5 @@
import { FakerError } from '../../../src/errors/faker-error';
+import { CI_PREFLIGHT } from '../../env';
import type { SourceableNode } from './source';
import { getSourcePath } from './source';
@@ -6,14 +7,22 @@ export class FakerApiDocsProcessingError extends FakerError {
constructor(options: {
type: string;
name: string;
- source: string | SourceableNode;
+ source: SourceableNode;
cause: unknown;
}) {
const { type, name, source, cause } = options;
- const sourceText =
- typeof source === 'string' ? source : getSourcePathText(source);
+
+ const mainText = `Failed to process ${type} '${name}'`;
const causeText = cause instanceof Error ? cause.message : '';
- super(`Failed to process ${type} ${name} at ${sourceText} : ${causeText}`, {
+ const { filePath, line, column } = getSourcePath(source);
+ const sourceText = `${filePath}:${line}:${column}`;
+
+ if (CI_PREFLIGHT) {
+ const sourceArgs = `file=${filePath},line=${line},col=${column}`;
+ console.log(`::error ${sourceArgs}::${mainText}: ${causeText}`);
+ }
+
+ super(`${mainText} at ${sourceText} : ${causeText}`, {
cause,
});
}
@@ -22,7 +31,7 @@ export class FakerApiDocsProcessingError extends FakerError {
export function newProcessingError(options: {
type: string;
name: string;
- source: string | SourceableNode;
+ source: SourceableNode;
cause: unknown;
}): FakerApiDocsProcessingError {
const { cause } = options;
@@ -33,8 +42,3 @@ export function newProcessingError(options: {
return new FakerApiDocsProcessingError(options);
}
-
-function getSourcePathText(source: SourceableNode): string {
- const { filePath, line, column } = getSourcePath(source);
- return `${filePath}:${line}:${column}`;
-}