What we're doing in the errors.xml is to group exceptions according to their nature.
Each group has an specific Exception class that will be used in case an exception within the group is raised to. In the example above, look the exception-class attribute declare for each group.
To use an error table has 3 main advantages:
It decouples the usage of an exception class or the other one depending on a given error, making it transparent to our application.
It eases the internationalization of our exception messages. See pkg.
It eases the maintenance of all our exceptions within a single place as well as the assignment of error codes
The Exception Factory
The __ExceptionFactory is a class in charge of create exceptions according to the error table.
It basically receives a given error code in order to create the most appropriate exception according to how it has been declared in the error table
In this example, the __ExceptionFactory takes as argument an exception code (ERR_WRONG_USERNAME_OR_PASSWORD), so it will create a MySecurityExceptionClass exception supposing we are using the error table above.
It's also important to note that, in our example, the MySecurityExceptionClass will have the error code 76002 as we have declared in our error table