templates/Doc/error.html.twig line 1

Open in your IDE?
  1. {% extends 'Layouts/Doc/default.html.twig' %}
  2. {% block title %}Documentation
  3. {% endblock %}
  4. {% block headerPageTitle %}
  5.     {{ 'app.documentation.page.title.error'|trans |upper}}
  6. {% endblock %}
  7. {% macro renderTree(node, level) %}
  8.     {% set badgeClass = {
  9.         0: 'light-primary',
  10.         1: 'light-info',
  11.         2: 'light-warning',
  12.         3: 'light-success',
  13.         4: 'secondary',
  14.     }[level]|default('secondary') %}
  15.     <li class="list-group-item">
  16.         <span class="d-block mb-2">{{ node.name|badge(badgeClass) }}</span>
  17.         {% if node.messages is not empty %}
  18.             <ul class="list-group ms-4">
  19.                 {% for message in node.messages %}
  20.                     <li class="list-group-item">=> {{ message }}</li>
  21.                 {% endfor %}
  22.             </ul>
  23.         {% endif %}
  24.         {% if node.children is not empty %}
  25.             <ul class="list-group ms-4">
  26.                 {% for childPath, childNode in node.children %}
  27.                     {{ _self.renderTree(childNode, level + 1) }}
  28.                 {% endfor %}
  29.             </ul>
  30.         {% endif %}
  31.     </li>
  32. {% endmacro %}
  33. {% block body %}
  34.     <div class="card mb-12">
  35.         <div class="card-body flex-column px-5 py-3">
  36.             <div class="d-flex align-items-center h-lg-300px px-5 py-3 p-lg-15">
  37.                 <div class="row">
  38.                     <div class="col-md-8 pt-5 scroll-y">
  39.                         <h1 class="fw-bold fs-4 fs-lg-1 text-gray-800 mb-3">API errors responses</h1>
  40.                         <div class="position-relative w-100 text-gray-800">
  41.                             <p>Foxorder's API includes an error management system, this system allows users to have assistance in case of error.</p>
  42.                             <p>Depending on the type of errors, the error message is often explicit (typing, null, format, etc.) otherwise, it indicates the source of the error and possibly the solution.</p>
  43.                         </div>
  44.                     </div>
  45.                     <div class="col-md-4 text-center">
  46.                         <img alt="Logo" src="{{ asset( foxorders_doc ~ 'api-error.svg') }}" style="width:300px; height:auto">
  47.                     </div>
  48.                 </div>
  49.             </div>
  50.         </div>
  51.     </div>
  52.     <div class="card">
  53.         <div class="card-body">
  54.             <div class="table-responsive">
  55.                 <table class="table table-row-bordered table-row-dashed gy-4 align-middle fw-bold">
  56.                     <thead class="fs-7 text-gray-400 text-uppercase">
  57.                         <tr>
  58.                             <th class="min-w-250px">Endpoint</th>
  59.                             <th class="min-w-90px text-center">Method</th>
  60.                             <th class="min-w-250px text-center">Error code => message</th>
  61.                         </tr>
  62.                     </thead>
  63.                     <tbody class="fs-6 text-gray-800">
  64.                         {% for group in apis %}
  65.                             {% if section is null %}
  66.                                 <tr>
  67.                                     <td colspan="8" class="text-center bg-light-dark">
  68.                                         {{ group.group|upper }}
  69.                                     </td>
  70.                                 </tr>
  71.                             {% endif %}
  72.                             {% set authorized = 'app.documentation.badge.authorized'|trans|badge('light-success', false) %}
  73.                             {% set unauthorized = 'app.documentation.badge.unauthorized'|trans|badge('light-danger', false) %}
  74.                             {% for value in group.list %}
  75.                                 {% if value.errors is defined %}
  76.                                     <tr style="border-bottom: 1px solid #cccccc;">
  77.                                         <td><span class="mb-1 text-hover-primary">{{ value.api }}</span></td>
  78.                                         <td class="text-center">
  79.                                             {% set typeClass = {
  80.                                                 'POST': 'warning',
  81.                                                 'PUT': 'primary',
  82.                                                 'PATCH': 'info',
  83.                                                 'DELETE': 'danger'
  84.                                             }[value.type]|default('success') %}
  85.                                             {{ value.type|upper|badge('light-' ~ typeClass, false) }}
  86.                                         </td>
  87.                                         <td>
  88.                                             <ul class="list-group">
  89.                                             {% for err in value.errors %}
  90.                                                 <li class="list-group-item">
  91.                                                     <span class="text-hover-primary d-block">{{ err.code|badge('light-danger') }} => {{ err.message }}</span>
  92.                                                     {% if err.violations is defined %}
  93.                                                         <ul class="list-group mt-3">
  94.                                                             {% for nodePath, node in err.violations %}
  95.                                                                 {{ _self.renderTree(node, 0) }}
  96.                                                             {% endfor %}
  97.                                                         </ul>
  98.                                                     {% endif %}
  99.                                                 </li>
  100.                                             {% endfor %}
  101.                                             </ul>
  102.                                         </td>
  103.                                     </tr>
  104.                                 {% endif %}
  105.                             {% else %}
  106.                                 <tr>
  107.                                     <td colspan="8" style='color:orange'>{{ 'app.global.detail.no_record_found'|trans }}</td>
  108.                                 </tr>
  109.                             {% endfor %}
  110.                         {% else %}
  111.                             <tr>
  112.                                 <td colspan="8" style='color:orange'>{{ 'app.global.detail.no_record_found'|trans }}</td>
  113.                             </tr>
  114.                         {% endfor %}
  115.                     </tbody>
  116.                 </table>
  117.             </div>
  118.         </div>
  119.     </div>
  120. {% endblock %}