|
| 1 | +.. _configuring-user-error-messages: |
| 2 | + |
| 3 | +Configuring User Error Messages |
| 4 | +------------------------------- |
| 5 | + |
| 6 | +There is an option to provide additional information to the user when a violation is found. |
| 7 | +This is accomplished by using the :code:`user_error_message` option. |
| 8 | +Setting this option for a rule will append the message to the normal output. |
| 9 | + |
| 10 | +Example without :code:`user_error_message` defined |
| 11 | +################################################## |
| 12 | + |
| 13 | +Applying a custom regex does not provide additional information to the user. |
| 14 | + |
| 15 | +Given the following configuration file which defines a custom regex: |
| 16 | + |
| 17 | +.. code-block:: yaml |
| 18 | +
|
| 19 | + rule: |
| 20 | + group: |
| 21 | + case::name: |
| 22 | + case: regex |
| 23 | + regex: (?![a-z||0-9]\u005F)(?!.*\u005F[a-z||0-9]$)([a-z||0-9]+(?:\u005F[a-z||0-9]+)*) |
| 24 | +
|
| 25 | +The following error report is generated: |
| 26 | + |
| 27 | +.. code-block:: bash |
| 28 | +
|
| 29 | + $vsg -f original.vhd -c config.yaml |
| 30 | + ================================================================================ |
| 31 | + File: original.vhd |
| 32 | + ================================================================================ |
| 33 | + Phase 6 of 7... Reporting |
| 34 | + Total Rules Checked: 857 |
| 35 | + Total Violations: 2 |
| 36 | + Error : 2 |
| 37 | + Warning : 0 |
| 38 | + -------------+------------+------------+-------------------------------------- |
| 39 | + Rule | severity | line(s) | Solution |
| 40 | + -------------+------------+------------+-------------------------------------- |
| 41 | + entity_008 | Error | 2 | Format FIFO to match defined regex |
| 42 | + entity_012 | Error | 3 | Format FIFO to match defined regex |
| 43 | + -------------+------------+------------+-------------------------------------- |
| 44 | + NOTE: Refer to online documentation at https://vhdl-style-guide.readthedocs.io/en/latest/index.html for more information. |
| 45 | +
|
| 46 | +Example with :code:`user_error_message` defined |
| 47 | +############################################### |
| 48 | + |
| 49 | +Adding a custom error message can provide additional information to the user: |
| 50 | + |
| 51 | +.. code-block:: yaml |
| 52 | +
|
| 53 | + rule: |
| 54 | + group: |
| 55 | + case::name: |
| 56 | + case: regex |
| 57 | + regex: (?![a-z||0-9]\u005F)(?!.*\u005F[a-z||0-9]$)([a-z||0-9]+(?:\u005F[a-z||0-9]+)*) |
| 58 | + user_error_message: "UPPERCASE and single letter prefix/suffix not allowed" |
| 59 | +
|
| 60 | +The following error report is generated: |
| 61 | + |
| 62 | +.. code-block:: bash |
| 63 | +
|
| 64 | + $vsg -f original.vhd -c config.yaml |
| 65 | + ================================================================================ |
| 66 | + File: original.vhd |
| 67 | + ================================================================================ |
| 68 | + Phase 6 of 7... Reporting |
| 69 | + Total Rules Checked: 857 |
| 70 | + Total Violations: 2 |
| 71 | + Error : 2 |
| 72 | + Warning : 0 |
| 73 | + -------------+------------+------------+-------------------------------------- |
| 74 | + Rule | severity | line(s) | Solution |
| 75 | + -------------+------------+------------+-------------------------------------- |
| 76 | + entity_008 | Error | 2 | Format FIFO to match defined regex [user_error_message: UPPERCASE and single letter prefix/suffix not allowed] |
| 77 | + entity_012 | Error | 3 | Format FIFO to match defined regex [user_error_message: UPPERCASE and single letter prefix/suffix not allowed] |
| 78 | + -------------+------------+------------+-------------------------------------- |
| 79 | + NOTE: Refer to online documentation at https://vhdl-style-guide.readthedocs.io/en/latest/index.html for more information. |
0 commit comments