Fix error_get_last() not cleared when error handle function entered

This also :
  - make get_last_error() not available in error handler like
    PHP, see http://3v4l.org/QKQKY
  - clear last error when request shutdown, prevent errmessage
    leak to the next request

Closes #4407