auth/web/template/error.qtpl

45 lines
824 B
Plaintext

{% package template %}
{% import (
"errors"
"source.toby3d.me/toby3d/auth/internal/domain"
"source.toby3d.me/toby3d/auth/web/template/layout"
) %}
{% code type Error struct {
layout.BaseOf
Error error
} %}
{% stripspace %}
{% func (p *Error) Title() %}
{%= p.T("Error") %}
{% endfunc %}
{% func (p *Error) Body() %}
<main>
{% code err := new(domain.Error) %}
{% if errors.As(p.Error, err) %}
<h1>{%s err.Code.String() %}</h1>
{% if err.Description != "" %}
<p>{%s err.Description %}</p>
{% endif %}
{% if err.URI != "" %}
<a rel="noreferrer noopener"
href="{%s err.URI %}"
target="_blank">
{%= p.T("How do I fix it?") %}
</a>
{% endif %}
{% else %}
<h1>{%= p.T("Error") %}</h1>
<p>{%s p.Error.Error() %}</p>
{% endif %}
</main>
{% endfunc %}
{% endstripspace %}