effect-errors 1.0.4 → 1.0.6

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.
@@ -1,4 +1,20 @@
1
1
  "use strict";
2
+ var __read = (this && this.__read) || function (o, n) {
3
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
4
+ if (!m) return o;
5
+ var i = m.call(o), r, ar = [], e;
6
+ try {
7
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
+ }
9
+ catch (error) { e = { error: error }; }
10
+ finally {
11
+ try {
12
+ if (r && !r.done && (m = i["return"])) m.call(i);
13
+ }
14
+ finally { if (e) throw e.error; }
15
+ }
16
+ return ar;
17
+ };
2
18
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
19
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
20
  };
@@ -10,13 +26,22 @@ var Predicate_1 = require("effect/Predicate");
10
26
  var cwdRegex = new RegExp("".concat(process.cwd()), 'g');
11
27
  var prettyErrorMessage = function (u) {
12
28
  if (typeof u === 'string') {
13
- return "Error: ".concat(u);
29
+ return "\uD83D\uDCA5 ".concat(u);
30
+ }
31
+ if (u instanceof Error && (0, Predicate_1.hasProperty)(u, 'error')) {
32
+ return "\uD83D\uDCA5 ".concat(chalk_1.default.bgRed(" ".concat(u.name, " ")), " ").concat(chalk_1.default.bold.whiteBright("\u2022 ".concat(u.error)), "\r\n");
14
33
  }
15
34
  if ((0, Predicate_1.hasProperty)(u, 'toString') &&
16
35
  (0, Function_1.isFunction)(u['toString']) &&
17
36
  u['toString'] !== Object.prototype.toString &&
18
37
  u['toString'] !== Array.prototype.toString) {
19
- return u['toString']();
38
+ var message = u['toString']();
39
+ var maybeWithUnderlyingType = message.split(': ');
40
+ if (maybeWithUnderlyingType.length > 1) {
41
+ var _a = __read(maybeWithUnderlyingType), type = _a[0], message_1 = _a.slice(1);
42
+ return "\uD83D\uDCA5 ".concat(chalk_1.default.bgRed(" ".concat(type, " ")), " ").concat(chalk_1.default.bold.whiteBright("\u2022 ".concat(message_1)));
43
+ }
44
+ return "\uD83D\uDCA5 ".concat(message);
20
45
  }
21
46
  if ((0, Predicate_1.hasProperty)(u, '_tag') && (0, Predicate_1.hasProperty)(u, 'message')) {
22
47
  var message = u.message
@@ -24,7 +49,7 @@ var prettyErrorMessage = function (u) {
24
49
  .hex('#c25c30')(u.message)
25
50
  .replace(cwdRegex, '.')
26
51
  : undefined;
27
- return "\uD83D\uDCA5 ".concat(chalk_1.default.bgRed(" ".concat(u._tag, " ")), " ").concat(message ? "\u2022 ".concat(message) : '', "\r\n");
52
+ return "\uD83D\uDCA5 ".concat(chalk_1.default.bgRed(" ".concat(u._tag, " ")), " ").concat(message ? chalk_1.default.bold.whiteBright("\u2022 ".concat(message)) : '', "\r\n");
28
53
  }
29
54
  return "Error: ".concat(JSON.stringify(u));
30
55
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "repository": "https://github.com/jpb06/effect-errors.git",
3
3
  "main": "dist/index.js",
4
4
  "name": "effect-errors",
5
- "version": "1.0.4",
5
+ "version": "1.0.6",
6
6
  "author": "jpb06 <jp.bois.06@outlook.fr>",
7
7
  "description": "Getting user stats from github",
8
8
  "keywords": [],
package/pretty-print.js CHANGED
@@ -21,9 +21,6 @@ var prettyPrint = function (cause) {
21
21
  return failures
22
22
  .map(function (_a) {
23
23
  var message = _a.message, stack = _a.stack, span = _a.span;
24
- if (stack) {
25
- message += "\r\n".concat((0, filter_stack_1.filterStack)(stack));
26
- }
27
24
  if (span) {
28
25
  var current = span;
29
26
  var spans_1 = [];
@@ -47,6 +44,9 @@ var prettyPrint = function (cause) {
47
44
  })
48
45
  .join('');
49
46
  }
47
+ if (stack) {
48
+ message += "\r\n".concat(span ? '\r\n' : '', "\uD83D\uDEA8 Stacktrace:\r\n").concat(chalk_1.default.red((0, filter_stack_1.filterStack)(stack)));
49
+ }
50
50
  return message + '\r\n';
51
51
  })
52
52
  .join('\r\n');