code: def _get_oserror(error, *, encoder):
      try:
          msg = Image.core.getcodecstatus(error)
      except AttributeError:
          msg = ERRORS.get(error)
      if not msg:
          msg = f"{'encoder' if encoder else 'decoder'} error {error}"
      msg += f" when {'writing' if encoder else 'reading'} image file"
      return OSError(msg)
  
imports: from __future__ import annotations
  import io
  import itertools
  import struct
  import sys
  from typing import Any, NamedTuple
  from .None import Image
  from ._deprecate import deprecate
  from ._util import is_path
label_desc: Use image node_id 1 for calling a global function with example usage: _get_oserror(error) and returns: OSError