You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find YAMLExceptions too big when the parsed front matter is big because they include the whole source text. I decided to reformat an error a bit, for that I had to catch the parsing error using the obvious approach:
importparseMdWithFrontMatterfrom'gray-matter';import{YAMLException}from'js-yaml';try{constparsedContents=parseMdWithFrontMatter(contents);// ...}catch(error){if(errorinstanceofYAMLException){// Format the error ...}throwerror;}
However, I was surprised when the error wasn't caught. It turned out I have my own js-yaml of a different major version (4.1.0), so technically imported YAMLException was a different class.
I think for cases like this, importing (at least) YAMLException from underlying gray-matter would be beneficial. Although, feel free to correct me if I'm doing something wrong. And thank you for the lib! :)
I find
YAMLException
s too big when the parsed front matter is big because they include the whole source text. I decided to reformat an error a bit, for that I had to catch the parsing error using the obvious approach:However, I was surprised when the error wasn't caught. It turned out I have my own
js-yaml
of a different major version (4.1.0), so technically importedYAMLException
was a different class.I think for cases like this, importing (at least)
YAMLException
from underlyinggray-matter
would be beneficial. Although, feel free to correct me if I'm doing something wrong. And thank you for the lib! :)P.S. My workaround:
The text was updated successfully, but these errors were encountered: