ui: Surface 'detail' of API errors in the error page (#9237)

* ui: Surface 'detail' of API errors in the error page

* Make UI generated 404s look less bare
This commit is contained in:
John Cowen 2020-11-19 16:07:23 +00:00 committed by hashicorp-ci
parent 023618e018
commit 1ea9592707
4 changed files with 16 additions and 8 deletions

View File

@ -1,5 +1,8 @@
{{yield}} {{yield}}
<div class="empty-state" ...attributes> <div
class="empty-state"
...attributes
>
{{#if hasHeader}} {{#if hasHeader}}
<header> <header>
{{#yield-slot name="header"}} {{#yield-slot name="header"}}

View File

@ -12,13 +12,19 @@
</BlockSlot> </BlockSlot>
{{/if}} {{/if}}
<BlockSlot @name="body"> <BlockSlot @name="body">
{{#if error.detail}}
<p>
{{error.detail}}
</p>
{{else}}
<p> <p>
You may have visited a URL that is loading an unknown resource, so you can try going back to the root or try re-submitting your ACL Token/SecretID by going back to ACLs. You may have visited a URL that is loading an unknown resource, so you can try going back to the root or try re-submitting your ACL Token/SecretID by going back to ACLs.
</p> </p>
{{/if}}
</BlockSlot> </BlockSlot>
<BlockSlot @name="actions"> <BlockSlot @name="actions">
<li class="back-link"> <li class="back-link">
<a data-test-home rel="home" href={{href-to 'index'}}>Go back to root</a> <a data-test-home rel="home" href={{href-to 'index'}}>Go back</a>
</li> </li>
<li class="docs-link"> <li class="docs-link">
<a href="{{env 'CONSUL_DOCS_URL'}}" rel="noopener noreferrer" target="_blank">Read the documentation</a> <a href="{{env 'CONSUL_DOCS_URL'}}" rel="noopener noreferrer" target="_blank">Read the documentation</a>

View File

@ -41,7 +41,7 @@ export default Route.extend(WithBlockingActions, {
}; };
if (e.errors && e.errors[0]) { if (e.errors && e.errors[0]) {
error = e.errors[0]; error = e.errors[0];
error.message = error.title || error.detail || 'Error'; error.message = error.message || error.title || error.detail || 'Error';
} }
if (error.status === '') { if (error.status === '') {
error.message = 'Error'; error.message = 'Error';

View File

@ -26,9 +26,8 @@ export default class DcService extends RepositoryService {
}); });
} }
} }
const e = new Error(); const e = new Error('Page not found');
e.status = '404'; e.status = '404';
e.detail = 'Page not found';
return Promise.reject({ errors: [e] }); return Promise.reject({ errors: [e] });
} }