Bug found in get_last_error

Fixed bug in get_last_error that didn't allow a correct working of the error reporting.