# 10.2 Severity and classes

> Severity says what to do with a diagnostic: an error prevents running, a warning tells you and lets you continue.

Web page: https://pseudolearn.app/en/spec/diagnosticos/severidad

> **In one sentence**
>
> Severity says what to do with a diagnostic: an error prevents running, a warning tells you and lets you continue.

## 10.2.1 How it works

Every code has **a single severity**, fixed in the catalogue and independent of its class. They are grouped by a letter:

| Letter | Severity | Examples |
| --- | --- | --- |
| A | structural error or runtime failure | `missingStatementTerminator`, `divisionByZero` |
| C | hygiene warning | `variableDeclaredNeverUsed` |
| D | information | suggestions without consequence |
| E | recoverable reading warning | `readValueTypeMismatch` |

The letter B is not assigned.

**Figure 10.2-1: Classes and severities**

At the top, the four classes in order: lexical, syntactic and semantic before running, and runtime during. Below, the four severity letters: A error, C hygiene, D information and E reading.

Classes say in which phase the problem is detected; severity, what consequence it has.

Classes follow the program's journey: **lexical** and **syntactic** while reading the text, **semantic** while checking types and names, and **runtime** while it runs. If there are lexical or syntactic errors, the semantic phase does not run: that way no errors derived from a broken tree appear.

A warning stops nothing. When reading a value that does not fit the type, the engine warns and **asks again**, without changing the variable:

### Program: A read that is repeated

```pseudolearn
Algorithm Edad
  Define edad As Integer;
  Read edad;
  Write "Tienes ", edad;
EndAlgorithm
```

**Input**

```text
doce
12
```

**Output**

```text
Tienes 12
```

**Diagnostics**
- `readValueTypeMismatch` (warning, 3:3): Expected a value of type Entero, and received doce

*The program finishes normally.*

> **Limit**
>
> A defect in the engine itself is never shown as a program error. It is caught at the boundary and produces an **internal failure** distinct from any diagnostic. No program, valid or not, should cause it.

**In short**
- Every code has a fixed severity: A error, C hygiene, D information, E reading.
- Classes give the phase: lexical, syntactic, semantic or runtime.
- With syntax errors no semantic analysis is done.

**See also**
- [10.1 Anatomy of a diagnostic](https://pseudolearn.app/en/spec/diagnosticos/anatomia.md)
- [10.3 Recovery and order](https://pseudolearn.app/en/spec/diagnosticos/recuperacion.md)
- [5.6 Unused variables](https://pseudolearn.app/en/spec/declaraciones/sin-usar.md)
