read-data-file 2.0.8 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/rdf.mjs +10 -4
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  { "name": "read-data-file",
2
- "version": "2.0.8",
2
+ "version": "2.0.9",
3
3
  "description": "Read data/config files in various formats (parsers list is configurable).",
4
4
  "keywords": [
5
5
  "read data file",
package/rdf.mjs CHANGED
@@ -2,13 +2,13 @@
2
2
 
3
3
  import pathLib from 'path';
4
4
  import nodeFs from 'fs';
5
- import pify from 'pify';
6
5
 
7
6
  import getOwn from 'getown';
8
7
  import ifFun from 'if-fun';
9
8
  import isStr from 'is-string';
10
9
  import mapObj from 'map-assoc-core';
11
10
  import mergeOpts from 'merge-options';
11
+ import pify from 'pify';
12
12
  import stripBom from 'strip-bom';
13
13
 
14
14
  import cesonParser from 'ceson/parse.js';
@@ -114,9 +114,15 @@ const defaultImpl = {
114
114
  const rop = this.findBestReaderAndParser(dotParts);
115
115
  if (!rop) { return this.unsupportedFext(realPath); }
116
116
  const { reader, parser } = rop;
117
- const content = await ifFun(reader, this.defaultReader)(realPath);
118
- const data = await ifFun(parser, identity)(content);
119
- return data;
117
+ try {
118
+ const content = await ifFun(reader, this.defaultReader)(realPath);
119
+ const data = await ifFun(parser, identity)(content);
120
+ return data;
121
+ } catch (err) {
122
+ err.dataFilePath = path;
123
+ err.message += ' — Error occurred while trying to read file ' + path;
124
+ throw err;
125
+ }
120
126
  },
121
127
 
122
128
  },