UNPKG

@har-sdk/core

Version:

The base package can be used to import specification files (i.e. HAR, OAS and Postman Collection) and detect their type.

25 lines 937 B
import { BaseSyntaxErrorDetailsExtractor } from './BaseSyntaxErrorDetailsExtractor'; export class YamlSyntaxErrorDetailsExtractor extends BaseSyntaxErrorDetailsExtractor { constructor() { super(...arguments); this.LOCATION_PATTERN = /\((\d+):(\d+)\)$/; } extractMessage(error) { const [mainMessage] = error.message.split('\n'); return mainMessage .replace(/^YAMLException: /, '') .replace(this.LOCATION_PATTERN, '') .trim(); } extractOffset(error) { const [mainMessage] = error.message.split('\n'); const matchRes = mainMessage.match(this.LOCATION_PATTERN); return matchRes ? this.calculateOffset(+matchRes[1], +matchRes[2]) : undefined; } extractSnippet(error) { return error.message.split('\n').slice(2).join('\n'); } } //# sourceMappingURL=YamlSyntaxErrorDetailsExtractor.js.map