Skip to content

Commit b98822f

Browse files
authored
Merge pull request #41 from embermap/display-errors
Display errors
2 parents 20501fe + fd484dd commit b98822f

35 files changed

Lines changed: 117 additions & 24 deletions

File tree

.ember-cli

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55

66
Setting `disableAnalytics` to true will prevent any data from being sent.
77
*/
8-
"disableAnalytics": false
8+
"disableAnalytics": false,
9+
"usePods": true
910
}

addon-test-support/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ export async function fastboot(url, { headers = {} }) {
1717
let response = await fetch(endpoint);
1818
let result = await response.json();
1919

20-
let body = extractBody(result.html);
20+
let body = result.err ?
21+
formatError(result.err) :
22+
extractBody(result.html);
2123

22-
result.body = body;
2324
result.htmlDocument = parseHtml(result.html)
25+
result.body = body;
2426

2527
return result;
2628
}
@@ -58,3 +60,7 @@ export function extractBody(html) {
5860

5961
return html.substr(startAt, endAt);
6062
}
63+
64+
let formatError = function(err) {
65+
return `<pre>${err.stack}</pre>`;
66+
};

index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,31 @@ module.exports = {
6565
html: html
6666
});
6767
});
68+
})
69+
.catch(err => {
70+
let errorObject;
71+
let jsonError = {};
72+
73+
errorObject = (typeof err === 'string') ?
74+
new Error(err) :
75+
err;
76+
77+
// we need to copy these properties off the error
78+
// object into a pojo that can be serialized and
79+
// sent over the wire to the test runner.
80+
let errorProps = [
81+
'description',
82+
'fileName',
83+
'lineNumber',
84+
'message',
85+
'name',
86+
'number',
87+
'stack'
88+
];
89+
90+
errorProps.forEach(key => jsonError[key] = errorObject[key]);
91+
92+
res.json({ err: jsonError });
6893
});
6994
});
7095
},

tests/dummy/app/components/.gitkeep

Whitespace-only changes.

tests/dummy/app/controllers/.gitkeep

Whitespace-only changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)