mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Added custom error pages, that assists users with common problems.
This commit is contained in:
parent
f36c618da9
commit
a0f5177533
7 changed files with 202 additions and 0 deletions
|
@ -13,3 +13,5 @@ twig:
|
||||||
locale_menu: '%partdb.locale_menu%'
|
locale_menu: '%partdb.locale_menu%'
|
||||||
attachment_manager: '@App\Services\Attachments\AttachmentManager'
|
attachment_manager: '@App\Services\Attachments\AttachmentManager'
|
||||||
label_profile_dropdown_helper: '@App\Services\LabelSystem\LabelProfileDropdownHelper'
|
label_profile_dropdown_helper: '@App\Services\LabelSystem\LabelProfileDropdownHelper'
|
||||||
|
error_page_admin_email: '%partdb.error_pages.admin_email%'
|
||||||
|
error_page_show_help: '%partdb.error_pages.show_help%'
|
||||||
|
|
|
@ -33,6 +33,12 @@ parameters:
|
||||||
partdb.attachments.dir.media: 'public/media/' # The folder where uploaded attachment files are saved (must be in public folder)
|
partdb.attachments.dir.media: 'public/media/' # The folder where uploaded attachment files are saved (must be in public folder)
|
||||||
partdb.attachments.dir.secure: 'uploads/' # The folder where secured attachment files are saved (must not be in public/)
|
partdb.attachments.dir.secure: 'uploads/' # The folder where secured attachment files are saved (must not be in public/)
|
||||||
|
|
||||||
|
######################################################################################################################
|
||||||
|
# Error pages
|
||||||
|
######################################################################################################################
|
||||||
|
partdb.error_pages.admin_email: '' # You can set an email address here, which is shown on an error page, how to contact an administrator
|
||||||
|
partdb.error_pages.show_help: false # If this is set to true, solutions to common problems are shown on error pages. Disable this, if you do not want your users to see them...
|
||||||
|
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
# Miscellaneous
|
# Miscellaneous
|
||||||
######################################################################################################################
|
######################################################################################################################
|
||||||
|
|
95
templates/bundles/TwigBundle/Exception/assets/error.css.twig
Normal file
95
templates/bundles/TwigBundle/Exception/assets/error.css.twig
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
body {
|
||||||
|
background-color: #fff;
|
||||||
|
color: #222;
|
||||||
|
font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
padding: 50px;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
margin-top: 10px;
|
||||||
|
color: #dc3545;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status_code {
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
font-size: 72px;
|
||||||
|
line-height: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status_text {
|
||||||
|
text-align: center;
|
||||||
|
line-height: 0.5;
|
||||||
|
font-size: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status_comment {
|
||||||
|
text-align: center;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help_text {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-muted {
|
||||||
|
color: #6c757d!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
display: table;
|
||||||
|
margin: 10px auto;
|
||||||
|
line-height: 1.4;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
box-sizing: border-box;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 60px;
|
||||||
|
line-height: 1.2;
|
||||||
|
text-align: left;
|
||||||
|
padding-top: 15px;
|
||||||
|
padding-left: 30px;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dev_hint {
|
||||||
|
margin-top: 45px;
|
||||||
|
line-height: 0.5;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
font-size: 87.5%;
|
||||||
|
color: #e83e8c;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
code, kbd, pre, samp {
|
||||||
|
font-family: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
kbd {
|
||||||
|
padding: .2rem .4rem;
|
||||||
|
font-size: 87.5%;
|
||||||
|
color: #fff;
|
||||||
|
background-color: #212529;
|
||||||
|
border-radius: .2rem;
|
||||||
|
}
|
53
templates/bundles/TwigBundle/Exception/error.html.twig
Normal file
53
templates/bundles/TwigBundle/Exception/error.html.twig
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
<meta name="robots" content="noindex,nofollow,noarchive" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<title>An Error Occurred: {{ status_text }}</title>
|
||||||
|
<style>{% include "bundles/TwigBundle/Exception/assets/error.css.twig" %}</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<h1 class="status_code">{% block status_code %}{{ status_code }}{% endblock %}</h1>
|
||||||
|
<h2 class="status_text">{% block status_text %}{{ status_text }}{% endblock %}</h2>
|
||||||
|
<h3 class="status_comment">
|
||||||
|
{% block status_comment %}
|
||||||
|
Consider yourself lucky. You found some rare error code. <br> You should maybe inform your administrator about it...
|
||||||
|
{% endblock %}
|
||||||
|
</h3>
|
||||||
|
{% block further_actions %}<p class="help_text">You can try to <a href="javascript:history.back()">Go Back</a> or <a href="{{ path('homepage') }}">Visit the homepage</a>.</p>{% endblock %}
|
||||||
|
{% block admin_contact %}<p class="help_text">If this error persists, please contact your
|
||||||
|
{% if error_page_admin_email is not empty %}
|
||||||
|
<a href="mailto:{{ error_page_admin_email }}">administrator.</a>
|
||||||
|
{% else %}
|
||||||
|
administrator.
|
||||||
|
{% endif %}
|
||||||
|
</p>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% if error_page_show_help %}
|
||||||
|
<div class="dev_hint">
|
||||||
|
<b>Infos for Admin:</b>
|
||||||
|
{% block admin_info %}
|
||||||
|
You could try to do following things, if this error is unexpected:
|
||||||
|
<ul>
|
||||||
|
<li>Check <code>var/log/prod.log</code> for additional informations</li>
|
||||||
|
<li>Run <kbd>php bin/console cache:clear</kbd> to clear cache</li>
|
||||||
|
</ul>
|
||||||
|
{% endblock %}
|
||||||
|
<p>If you think that this is an error in Part-DB, open an Issue on <a href="https://github.com/Part-DB/Part-DB-symfony/issues" rel="noopener">GitHub</a>.</p>
|
||||||
|
<p><small>You can disable these hints in <code>config/parameters.yaml</code> by setting <code>partdb.error_pages.show_help</code> to false.</small></p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="footer">
|
||||||
|
{% block footer %}
|
||||||
|
<span class="text-muted">This page was generated by <a href="https://github.com/Part-DB/Part-DB-symfony" rel="noopener">Part-DB</a> on {{ "now" | format_datetime("medium", "short") }} </span>.
|
||||||
|
{% endblock %}
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,6 @@
|
||||||
|
{% extends "bundles/TwigBundle/Exception/error.html.twig" %}
|
||||||
|
|
||||||
|
{% block status_comment %}
|
||||||
|
Nice try! But you are not allowed to do this!
|
||||||
|
<br> <small>If you think you should have access to this ressource, contact the adminstrator.</small>
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,5 @@
|
||||||
|
{% extends "bundles/TwigBundle/Exception/error.html.twig" %}
|
||||||
|
|
||||||
|
{% block status_comment %}
|
||||||
|
This page (or element) does not exist. Please check your URL.
|
||||||
|
{% endblock %}
|
35
templates/bundles/TwigBundle/Exception/error500.html.twig
Normal file
35
templates/bundles/TwigBundle/Exception/error500.html.twig
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{% extends "bundles/TwigBundle/Exception/error.html.twig" %}
|
||||||
|
|
||||||
|
{% block status_comment %}
|
||||||
|
Something bad happened internally.
|
||||||
|
<br>There is nothing you could do about this, except trying to reload the page.
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block admin_info %}
|
||||||
|
{% if exception.class == "Doctrine\\DBAL\\Exception\\ConnectionException" %}
|
||||||
|
<i>Can not connect to database.</i> Try follwing things:
|
||||||
|
<ul>
|
||||||
|
<li>Check if the database server is running</li>
|
||||||
|
<li>Ensure that <code>DATABASE_URL</code> in <code>.env.local</code> is correct: database name, user and password must be correct.</li>
|
||||||
|
<li>Ensure that the database user has access to the database.</li>
|
||||||
|
</ul>
|
||||||
|
{% elseif exception.class == "Twig\\Error\\RuntimeError" and 'manifest.json' in exception.message %}
|
||||||
|
<i>Can not load frontend assets.</i> Try following things:
|
||||||
|
<ul>
|
||||||
|
<li>Run <kbd>yarn install</kbd> and <kbd>yarn build</kbd> in Part-DB folder.</li>
|
||||||
|
<li>Run <kbd>php bin/console cache:clear</kbd></li>
|
||||||
|
</ul>
|
||||||
|
{% elseif exception.class == "Doctrine\\DBAL\\Exception\\InvalidFieldNameException" %}
|
||||||
|
<i>Invalid database schema.</i> Try following things:
|
||||||
|
<ul>
|
||||||
|
<li>Run <kbd>php bin/console doctrine:migrations:migrate</kbd> to upgrade database schema</li>
|
||||||
|
<li>Run <kbd>php bin/console cache:clear</kbd></li>
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
You could try following things, if this error is unexpected:
|
||||||
|
<ul>
|
||||||
|
<li>Check <code>var/log/prod.log</code> for additional informations</li>
|
||||||
|
<li>Run <kbd>php bin/console cache:clear</kbd> to clear cache</li>
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue