improve msg for better debug when OSError(related with #5632)

improve msg for better debug when OSError
changing to new except syntax
changing name of variables (err by e on exceptions)
improving msg for debugging issue #5632