I am working on a PHP library that can be used in different environments by different PHP projects, and I try to be as minimal as possible.
In some cases, I must, for example, throw exceptions.
throw Exception('template has invalid tag');
A similar error is not very useful without a tag name:
throw Exception('template has invalid tag: '.$tag);
This would be difficult to localize and could lead to any kind of injection.
QUESTION: What is the best way to pass extra variables with Exception to PHP?
(note: my library is building SQL Query, and I would prefer it to focus on the task rather than solving problems with exceptions)
source
share