I totally changed this function, preserving only error message resolution based on a error parameter, no matter if last or not. It can be usefull for PHP versions < 5.5.0. What do you think?