{"action":"created","issue":{"url":"https://api.github.com/repos/tapjs/node-tap/issues/220","labels_url":"https://api.github.com/repos/tapjs/node-tap/issues/220/labels{/name}","comments_url":"https://api.github.com/repos/tapjs/node-tap/issues/220/comments","events_url":"https://api.github.com/repos/tapjs/node-tap/issues/220/events","html_url":"https://github.com/tapjs/node-tap/issues/220","id":128876830,"number":220,"title":"Is it possible to overload `.fail`","user":{"login":"remy","id":13700,"avatar_url":"https://avatars.githubusercontent.com/u/13700?v=3","gravatar_id":"","url":"https://api.github.com/users/remy","html_url":"https://github.com/remy","followers_url":"https://api.github.com/users/remy/followers","following_url":"https://api.github.com/users/remy/following{/other_user}","gists_url":"https://api.github.com/users/remy/gists{/gist_id}","starred_url":"https://api.github.com/users/remy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/remy/subscriptions","organizations_url":"https://api.github.com/users/remy/orgs","repos_url":"https://api.github.com/users/remy/repos","events_url":"https://api.github.com/users/remy/events{/privacy}","received_events_url":"https://api.github.com/users/remy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-26T16:52:41Z","updated_at":"2016-01-26T19:43:12Z","closed_at":null,"body":"I'm running tests in travis where combine promises with tap, for instance:\r\n\r\n```js\r\ntap.test('example', function (t) {\r\n  new Promise(function () {\r\n    throw new Error('undefined');\r\n  }).catch(t.fail).then(t.end);\r\n});\r\n```\r\n\r\nTypically the function actually throwing the error is deep inside my code. The problem I have is that tap reports the `error.message` string which is helpful, but even more helpful if I had a full stack trace from the error.\r\n\r\nIs there any known way to make tap to read the `error.stack` instead of `error.message` when echoing a failure?\r\n\r\nRelated - I tried messing with the `Error` object, but it didn't work either:\r\n\r\n```js\r\nError.prototype.toString = function() { return this.stack; };\r\n```\r\n\r\nObviously I could change all my `catch` calls to be the following, but I wanted to explore this option too...\r\n\r\n```js\r\n.catch(function (e) {\r\n  t.fail(e.stack);\r\n})..."},"comment":{"url":"https://api.github.com/repos/tapjs/node-tap/issues/comments/175195350","html_url":"https://github.com/tapjs/node-tap/issues/220#issuecomment-175195350","issue_url":"https://api.github.com/repos/tapjs/node-tap/issues/220","id":175195350,"user":{"login":"isaacs","id":9287,"avatar_url":"https://avatars.githubusercontent.com/u/9287?v=3","gravatar_id":"","url":"https://api.github.com/users/isaacs","html_url":"https://github.com/isaacs","followers_url":"https://api.github.com/users/isaacs/followers","following_url":"https://api.github.com/users/isaacs/following{/other_user}","gists_url":"https://api.github.com/users/isaacs/gists{/gist_id}","starred_url":"https://api.github.com/users/isaacs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaacs/subscriptions","organizations_url":"https://api.github.com/users/isaacs/orgs","repos_url":"https://api.github.com/users/isaacs/repos","events_url":"https://api.github.com/users/isaacs/events{/privacy}","received_events_url":"https://api.github.com/users/isaacs/received_events","type":"User","site_admin":false},"created_at":"2016-01-26T19:43:12Z","updated_at":"2016-01-26T19:43:12Z","body":"Here's the output that these two produce:\r\n\r\n```\r\n$ cat return-promise.js\r\nvar tap = require('tap')\r\ntap.test('example', function (t) {\r\n  return new Promise(function () {\r\n    throw new Error('undefined');\r\n  });\r\n});\r\n\r\n$ tap return-promise.js\r\nreturn-promise.js ..................................... 0/1\r\n  example\r\n  not ok undefined\r\n    at:\r\n      line: 4\r\n      column: 11\r\n      file: return-promise.js\r\n    message: 'Error: undefined'\r\n    source: |\r\n      throw new Error('undefined');\r\n    stack: |\r\n      return-promise.js:4:11\r\n      return-promise.js:3:10\r\n      Test.runChild [as _runChild] (lib/test.js:513:17)\r\n      lib/test.js:423:10\r\n      loop (lib/test.js:479:12)\r\n      Test._runBeforeEach (lib/test.js:434:5)\r\n      Test.test (lib/test.js:422:8)\r\n      Object.<anonymous> (return-promise.js:2:5)\r\n\r\ntotal ................................................. 0/1\r\n\r\n\r\n  0 passing (260.437ms)\r\n  1 failing\r\n\r\n\r\n$ node return-promise.js\r\nTAP version 13\r\n    # Subtest: example\r\n    not ok 1 - undefined\r\n      ---\r\n      at:\r\n        line: 4\r\n        column: 11\r\n        file: return-promise.js\r\n      message: 'Error: undefined'\r\n      source: |\r\n        throw new Error('undefined');\r\n      stack: |\r\n        return-promise.js:4:11\r\n        return-promise.js:3:10\r\n        Test.runChild [as _runChild] (lib/test.js:513:17)\r\n        lib/test.js:423:10\r\n        loop (lib/test.js:479:12)\r\n        Test._runBeforeEach (lib/test.js:434:5)\r\n        Test.test (lib/test.js:422:8)\r\n        Object.<anonymous> (return-promise.js:2:5)\r\n      ...\r\n    1..1\r\n    # failed 1 of 1 tests\r\nnot ok 1 - example # time=18.923ms\r\n  ---\r\n  at:\r\n    line: 2\r\n    column: 5\r\n    file: return-promise.js\r\n  results:\r\n    plan:\r\n      start: 1\r\n      end: 1\r\n    count: 1\r\n    pass: 0\r\n    ok: false\r\n    fail: 1\r\n    time: 18.923\r\n  source: |\r\n    tap.test('example', function (t) {\r\n  ...\r\n\r\n1..1\r\n# failed 1 of 1 tests\r\n# time=42.213ms\r\n```\r\n\r\n```\r\n$ cat handle-promise.js\r\nvar tap = require('tap')\r\ntap.test('example', function (t) {\r\n  new Promise(function () {\r\n    throw new Error('undefined');\r\n  }).catch(t.threw).then(doOtherStuffOrWhatever);\r\n});\r\n\r\nfunction doOtherStuffOrWhatever() {\r\n  return new Promise(function (resolve) { resolve() })\r\n}\r\n\r\n$ node handle-promise.js\r\nTAP version 13\r\n    # Subtest: example\r\n    not ok 1 - Error: undefined\r\n      ---\r\n      at:\r\n        line: 4\r\n        column: 11\r\n        file: handle-promise.js\r\n      test: example\r\n      message: 'Error: undefined'\r\n      source: |\r\n        throw new Error('undefined');\r\n      stack: |\r\n        handle-promise.js:4:11\r\n        handle-promise.js:3:3\r\n        Test.runChild [as _runChild] (lib/test.js:513:17)\r\n        lib/test.js:423:10\r\n        loop (lib/test.js:479:12)\r\n        Test._runBeforeEach (lib/test.js:434:5)\r\n        Test.test (lib/test.js:422:8)\r\n        Object.<anonymous> (handle-promise.js:2:5)\r\n      ...\r\n    1..1\r\n    # failed 1 of 1 tests\r\nnot ok 1 - example # time=19.802ms\r\n  ---\r\n  at:\r\n    line: 2\r\n    column: 5\r\n    file: handle-promise.js\r\n  results:\r\n    plan:\r\n      start: 1\r\n      end: 1\r\n    count: 1\r\n    pass: 0\r\n    ok: false\r\n    fail: 1\r\n    time: 19.802\r\n  source: |\r\n    tap.test('example', function (t) {\r\n  ...\r\n\r\n1..1\r\n# failed 1 of 1 tests\r\n# time=42.372ms\r\n\r\n$ tap handle-promise.js\r\nhandle-promise.js ..................................... 0/1\r\n  example\r\n  not ok Error: undefined\r\n    at:\r\n      line: 4\r\n      column: 11\r\n      file: handle-promise.js\r\n    test: example\r\n    message: 'Error: undefined'\r\n    source: |\r\n      throw new Error('undefined');\r\n    stack: |\r\n      handle-promise.js:4:11\r\n      handle-promise.js:3:3\r\n      Test.runChild [as _runChild] (lib/test.js:513:17)\r\n      lib/test.js:423:10\r\n      loop (lib/test.js:479:12)\r\n      Test._runBeforeEach (lib/test.js:434:5)\r\n      Test.test (lib/test.js:422:8)\r\n      Object.<anonymous> (handle-promise.js:2:5)\r\n\r\ntotal ................................................. 0/1\r\n\r\n\r\n  0 passing (261.147ms)\r\n  1 failing\r\n```"}}