# uproot.KeyInFileError

Defined in [uproot.exceptions](https://github.com/scikit-hep/uproot5/blob/db953cf9827349b3d24eb6742404158c1dfd5481/src/uproot/exceptions.py) on [line 17](https://github.com/scikit-hep/uproot5/blob/db953cf9827349b3d24eb6742404158c1dfd5481/src/uproot/exceptions.py#L17).

| **Inheritance order:**                                                                                           |
|------------------------------------------------------------------------------------------------------------------|
| 1. `builtins.KeyError`<br/>2. `builtins.LookupError`<br/>3. `builtins.Exception`<br/>4. `builtins.BaseException` |

### *class* uproot.exceptions.KeyInFileError(key, because='', cycle=None, keys=None, file_path=None, object_path=None)

Exception raised by attempts to find ROOT objects in `TDirectories`
or `TBranches` in [uproot.behaviors.TBranch.HasBranches](uproot.behaviors.TBranch.HasBranches.html.md), which
both have a Python `Mapping` interface (square bracket syntax to extract
items).

This exception descends from Python’s `KeyError`, so it can be used in
the normal way by interfaces that expect a missing item in a `Mapping`
to raise `KeyError`, but it provides more information, depending on
availability:

* `because`: an explanatory message
* `cycle`: the ROOT cycle number requested, if any
* `keys`: a list or partial list of keys that *are* in the object, in case
  of misspelling
* `file_path`: a path (or URL) to the file
* `object_path`: a path to the object within the ROOT file.
