Skip to content

Commit 472b6f1

Browse files
authored
Provide basic docs on error messages (#327)
Comments added to the review page in the demo (and the source template) explain how to use the errors returned from the backend. In addition, the config page has a short paragraph in case the user thought they were edited there. This points them back to the review template.
1 parent 7866008 commit 472b6f1

3 files changed

Lines changed: 99 additions & 3 deletions

File tree

lib/importer/templates/review.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,26 @@ <h1 class="govuk-heading-l">Review your data</h1>
2424
{% if results.errors.length > 0 %}
2525
<h2 class="govuk-heading-m">Errors</h2>
2626
{% for errorObject in results.errors %}
27+
28+
{#
29+
This error object is generated when there was a problem processing the
30+
data. The error object contains a type, meta information and the rows that
31+
caused the error with some surrounding rows for context.
32+
33+
The meta information field contains:
34+
count - the number of times this error occurred
35+
first - the first row number where this error occurred
36+
37+
The type field contains information about the error that occurred, including
38+
the variant of error, possible values for which are:
39+
* FieldRequired
40+
* IncorrectType
41+
* MonthUnrecognised
42+
* MonthOutOfRange
43+
* DayOutOfRange
44+
* DayWrongType
45+
#}
46+
2747
{% set error = errorObject.type %}
2848
<div class="govuk-form-group govuk-form-group--error">
2949
<h2 class="govuk-heading-m validation-error-message">
@@ -62,6 +82,30 @@ <h2 class="govuk-heading-m validation-error-message">
6282
{% if results.warnings.length > 0 %}
6383
<h2 class="govuk-heading-m">Warnings</h2>
6484
{% for warningObject in results.warnings %}
85+
86+
{#
87+
This warning object is generated when there was a problem processing the
88+
data but it did not stop processing. These warnings are to alert the user to
89+
potential issues with the data.
90+
91+
The error object contains a type, meta information and the rows that
92+
caused the error with some surrounding rows for context.
93+
94+
The meta information field contains:
95+
count - the number of times this error occurred
96+
first - the first row number where this error occurred
97+
98+
The type field contains information about the error that occurred, including
99+
the variant of error, possible values for which are:
100+
* EmptyRow
101+
* ShortRow
102+
* UnknownDateFormat
103+
* UnrecognisableDateFormat
104+
* DateGuessing20thCentury
105+
* DateGuessing21stCentury
106+
#}
107+
108+
65109
{% set warning = warningObject.type %}
66110

67111
<div class="govuk-form-group govuk-form-group--error">

lib/importer/views/plugin_config.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ <h1 class="govuk-panel__title">
1919
{{ message }}
2020
</div>
2121
</div>
22-
2322
{% endif %}
2423

2524

@@ -177,7 +176,18 @@ <h1 class="govuk-fieldset__heading">
177176
</p>
178177
</fieldset>
179178
</div>
180-
</div>
179+
</div>
180+
181+
<div class="govuk-grid-column-full govuk-!-padding-top-6" >
182+
<h2 class="govuk-heading-l">Error messages</h2>
183+
184+
<p class="govuk-body">
185+
To update the error messages shown when there is a problem with the uploaded data,
186+
you can edit the messages in the review template, found in '<code>./app/views/review.html</code>'.
187+
This template checks the type of error and shows a relevant message. You can modify these messages
188+
to suit your needs.
189+
</p>
190+
</div>
181191

182192

183193
<div class="govuk-grid-column-full govuk-!-padding-top-6" >

prototypes/basic/app/views/review.html

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,27 @@ <h1 class="govuk-heading-l">Review your data</h1>
5959
{% if results.errors.length > 0 %}
6060
<h2 class="govuk-heading-m">Errors</h2>
6161
{% for errorObject in results.errors %}
62+
63+
{#
64+
This error object is generated when there was a problem processing the
65+
data. The error object contains a type, meta information and the rows that
66+
caused the error with some surrounding rows for context.
67+
68+
The meta information field contains:
69+
count - the number of times this error occurred
70+
first - the first row number where this error occurred
71+
72+
The type field contains information about the error that occurred, including
73+
the variant of error, possible values for which are:
74+
* FieldRequired
75+
* IncorrectType
76+
* MonthUnrecognised
77+
* MonthOutOfRange
78+
* DayOutOfRange
79+
* DayWrongType
80+
#}
81+
82+
6283
{% set error = errorObject.type %}
6384
<div class="govuk-form-group govuk-form-group--error">
6485
<h2 class="govuk-heading-m validation-error-message">
@@ -97,8 +118,29 @@ <h2 class="govuk-heading-m validation-error-message">
97118
{% if results.warnings.length > 0 %}
98119
<h2 class="govuk-heading-m">Warnings</h2>
99120
{% for warningObject in results.warnings %}
100-
{% set warning = warningObject.type %}
121+
{#
122+
This warning object is generated when there was a problem processing the
123+
data but it did not stop processing. These warnings are to alert the user to
124+
potential issues with the data.
125+
126+
The error object contains a type, meta information and the rows that
127+
caused the error with some surrounding rows for context.
128+
129+
The meta information field contains:
130+
count - the number of times this error occurred
131+
first - the first row number where this error occurred
132+
133+
The type field contains information about the error that occurred, including
134+
the variant of error, possible values for which are:
135+
* EmptyRow
136+
* ShortRow
137+
* UnknownDateFormat
138+
* UnrecognisableDateFormat
139+
* DateGuessing20thCentury
140+
* DateGuessing21stCentury
141+
#}
101142

143+
{% set warning = warningObject.type %}
102144
<div class="govuk-form-group govuk-form-group--error">
103145
<h2 class="govuk-heading-m validation-error-message">
104146
{% switch warning.variant %}

0 commit comments

Comments
 (0)