Skip to content

Commit 49bcb74

Browse files
pderaaijdjtarazona
authored andcommitted
adds pretty error printing for yaml parsing
1 parent 1ecd18b commit 49bcb74

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/loader.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const recursivelyLoadRulesets = async (ruleset, loadedRulesets, options) => {
119119
}
120120

121121
try {
122-
const data = yaml.parse(text);
122+
const data = yaml.parse(text, { prettyErrors: true });
123123

124124
loadedRulesets.push(ruleset);
125125

@@ -178,9 +178,9 @@ const loadSpec = async (source, options = {}) => {
178178
return await readSpecFile(source, options)
179179
.then(content => {
180180
try {
181-
return yaml.parse(content);
181+
return yaml.parse(content, { prettyErrors: true } );
182182
} catch (err) {
183-
throw new ReadError(err.message);
183+
throw new ReadError("\nLine: " + err.linePos.start.line + ", col: " + err.linePos.start.col + " " + err.message);
184184
}
185185
}, err => {
186186
throw new OpenError(err.message)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"oas-resolver": "^2.2.4",
4444
"oas-validator": "^3.0.1",
4545
"redoc": "v2.0.0-rc.8-1",
46-
"yaml": "^1.2.0"
46+
"yaml": "^1.5.0"
4747
},
4848
"devDependencies": {
4949
"babel-core": "^6.24.1",

0 commit comments

Comments
 (0)