@vbarbarosh/node-helpers 3.24.1 → 3.25.0

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Vladimir Barbarosh <vladimir.barbarosh@gmail.com>",
3
3
  "license": "MIT",
4
4
  "name": "@vbarbarosh/node-helpers",
5
- "version": "3.24.1",
5
+ "version": "3.25.0",
6
6
  "description": "A set of helpers for JavaScript/Node.js",
7
7
  "files": [
8
8
  "src"
@@ -1,5 +1,7 @@
1
+ const UserFriendlyError = require('./UserFriendlyError');
2
+
1
3
  // https://github.com/nodejs/node/issues/36084#issuecomment-729894622
2
- class AbortError extends Error
4
+ class AbortError extends UserFriendlyError
3
5
  {
4
6
  constructor(message = 'The operation was aborted') {
5
7
  super(message);
@@ -0,0 +1,8 @@
1
+ class UserFriendlyError extends Error
2
+ {
3
+ constructor(message) {
4
+ super(message);
5
+ }
6
+ }
7
+
8
+ module.exports = UserFriendlyError;
package/src/fastdl.js CHANGED
@@ -1,3 +1,4 @@
1
+ const UserFriendlyError = require('./errors/UserFriendlyError');
1
2
  const format_bytes = require('./format_bytes');
2
3
  const format_progress = require('./format_progress');
3
4
  const format_thousands = require('./format_thousands');
@@ -53,7 +54,7 @@ async function fastdl({file, read_stream_with_range, concurrency = 60, user_frie
53
54
  }
54
55
 
55
56
  if (total !== total_written) {
56
- throw new Error(`Total bytes written differs from size of a file: total[${total}] - total_written[${total_written}] = ${total - total_written}`);
57
+ throw new UserFriendlyError(`Total bytes written differs from expected size of a file: total[${total}] - total_written[${total_written}] = ${total - total_written}`);
57
58
  }
58
59
 
59
60
  function spawn() {
@@ -73,7 +74,7 @@ async function fastdl({file, read_stream_with_range, concurrency = 60, user_frie
73
74
  if (rs.content_range.total !== total) {
74
75
  rs.once('error', ignore);
75
76
  rs.destroy();
76
- throw new Error('Size of a file changed during download');
77
+ throw new UserFriendlyError('Size of a file changed during download');
77
78
  }
78
79
  const acc = new stream.PassThrough({
79
80
  transform(buf, encoding, next) {