Skip to content

Commit

Permalink
Fix: show actual errors on failed elements, handle null values from f…
Browse files Browse the repository at this point in the history
…unctions (elastic#32600)

Closes elastic#32356

This PR fixes two issues.

The first there was an issue filed, elastic#32356:

- Show non-Boom errors instead of asking users to look at server logs
  - Also write the error to the server when asking them to look there

![](https://user-images.githubusercontent.com/404731/53673728-9368b180-3c46-11e9-912e-7aaff25d3ddf.png)
*If the function failed for some reason, this is all you'd ever see*

![screenshot 2019-03-06 16 24 09](https://user-images.githubusercontent.com/404731/53921029-4d3b9580-402c-11e9-85bf-21ab31e952bc.png)
*Errors are shown to the user*

![screenshot 2019-03-06 16 26 16](https://user-images.githubusercontent.com/404731/53921130-a0154d00-402c-11e9-9cb5-102d360a69f8.png)
*Code errors bubble up correctly as well*

---

The other I didn't bother opening an issue for:

- Fixes issue where functions that return `null` produce an error message
  - `null` is a valid thing to return, it's only `undefined` that causes a problem
  - This was only a problem for server functions that return `null` (currently, none of them do)
  - Introduced in elastic#31298
  - Discovered when I ran into casting problems (see elastic#32597)

![screenshot 2019-03-06 16 18 17](https://user-images.githubusercontent.com/404731/53921039-562c6700-402c-11e9-9650-fc51d1f91643.png)

![screenshot 2019-03-06 16 19 01](https://user-images.githubusercontent.com/404731/53921044-5cbade80-402c-11e9-9cde-fdb49334dcd0.png)
  • Loading branch information
w33ble committed Mar 8, 2019
1 parent 5254c40 commit 78591cf
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ function runServerFunctions(server) {
.catch(err => {
if (Boom.isBoom(err)) {
return { err, statusCode: err.statusCode, message: err.output.payload };
} else if (err instanceof Error) {
return { err, statusCode: 500, message: err.message };
}

server.log(['interpreter', 'error'], err);
return { err: 'Internal Server Error', statusCode: 500, message: 'See server logs for details.' };
});

if (result == null) {
if (typeof result === 'undefined') {
const { functionName } = fnCall;
return {
id,
Expand Down

0 comments on commit 78591cf

Please sign in to comment.