yini-parser
Version:
Readable configuration without YAML foot-guns or JSON noise. The official Node.js parser for YINI config format — An INI-inspired configuration format with clear nesting, explicit types, and predictable parsing.
67 lines (65 loc) • 2.65 kB
TypeScript
import { IssuePayload } from '../types';
import { TBailSensitivityLevel, TIssueType, TSubjectType } from './internalTypes';
/**
* This class handles all error/notice reporting and processes exit/throwing.
*/
export declare class ErrorDataHandler {
private readonly subjectType;
private readonly fileName;
private readonly persistThreshold;
private readonly isQuiet;
private readonly isSilent;
private readonly isThrowOnError;
private errors;
private warnings;
private notices;
private infos;
private numFatalErrors;
private numInternalErrors;
private numSyntaxErrors;
private numSyntaxWarnings;
private numNotices;
private numInfos;
/** '1-Abort-on-Errors' is the default.
Below is from the YINI spec:
**Abort Sensitivity Levels** while parsing a YINI document:
(AKA severity threshold)
- Level 0 = ignore errors and try parse anyway (may remap falty key/section names)
- Level 1 = abort on errors only
- Level 2 = abort even on warnings
*/
constructor(subjectType: TSubjectType, fileName?: string | undefined, bailSensitivityLevel?: TBailSensitivityLevel, isQuiet?: boolean, // Reduce output (show only errors, does not effect warnings and etc. in meta data).
isSilent?: boolean, // Suppress all output (even errors, exit code only).
isThrowOnError?: boolean);
private makeIssue;
/**
* After pushing processing may continue or exit, depending on the error
* and/or the bail threshold (that can be optionally set by the user).
*
* @note This function MIGHT result in a return, throw, or exit depending
* on the bail policy (set by the user).
*
* @param ctx
* @param type
* @param msgWhat Name of the specific error or what failed. E.g. "Key already exists in this section scope".
* @param msgWhy More details and more specific info about the issue/error.
* @param msgHint Hint or HUMBLE suggestion on how to fix the issue.
*/
pushOrBail(ctx: any, type: TIssueType, msgWhat: string, msgWhy?: string, msgHint?: string): void;
private formatSignificantMessageLine;
private emitFatalError;
private emitInternalError;
private emitSyntaxError;
private emitSyntaxWarning;
private emitNotice;
private emitInfo;
getNumOfAllMessages(): number;
getNumOfErrors(): number;
getNumOfWarnings(): number;
getNumOfNotices(): number;
getNumOfInfos(): number;
getErrors(): IssuePayload[];
getWarnings(): IssuePayload[];
getNotices(): IssuePayload[];
getInfos(): IssuePayload[];
}