errors.d.ts 1.2 KB

123456789101112131415161718192021
  1. import type { LineCounter } from './parse/line-counter';
  2. export type ErrorCode = 'ALIAS_PROPS' | 'BAD_ALIAS' | 'BAD_DIRECTIVE' | 'BAD_DQ_ESCAPE' | 'BAD_INDENT' | 'BAD_PROP_ORDER' | 'BAD_SCALAR_START' | 'BLOCK_AS_IMPLICIT_KEY' | 'BLOCK_IN_FLOW' | 'DUPLICATE_KEY' | 'IMPOSSIBLE' | 'KEY_OVER_1024_CHARS' | 'MISSING_CHAR' | 'MULTILINE_IMPLICIT_KEY' | 'MULTIPLE_ANCHORS' | 'MULTIPLE_DOCS' | 'MULTIPLE_TAGS' | 'NON_STRING_KEY' | 'TAB_AS_INDENT' | 'TAG_RESOLVE_FAILED' | 'UNEXPECTED_TOKEN' | 'BAD_COLLECTION_TYPE';
  3. export type LinePos = {
  4. line: number;
  5. col: number;
  6. };
  7. export declare class YAMLError extends Error {
  8. name: 'YAMLParseError' | 'YAMLWarning';
  9. code: ErrorCode;
  10. message: string;
  11. pos: [number, number];
  12. linePos?: [LinePos] | [LinePos, LinePos];
  13. constructor(name: YAMLError['name'], pos: [number, number], code: ErrorCode, message: string);
  14. }
  15. export declare class YAMLParseError extends YAMLError {
  16. constructor(pos: [number, number], code: ErrorCode, message: string);
  17. }
  18. export declare class YAMLWarning extends YAMLError {
  19. constructor(pos: [number, number], code: ErrorCode, message: string);
  20. }
  21. export declare const prettifyError: (src: string, lc: LineCounter) => (error: YAMLError) => void;