Exceptions¶
All custom exception classes raised by idfkit.
Custom exceptions for idfkit.
ParseDiagnosticCode = Literal['UnknownObjectType', 'InvalidField', 'Range', 'DuplicateObject', 'ParseError', 'VersionMismatch', 'UnsupportedVersion', 'SchemaNotFound']
module-attribute
¶
ParseError = IdfKitError
module-attribute
¶
DanglingReferenceError
¶
Bases: IdfKitError
Raised when an object references a non-existent object.
Attributes:
| Name | Type | Description |
|---|---|---|
source |
The object holding the reference. |
|
field |
The field holding the reference. |
|
target |
The name that resolves to no object. |
|
suggestion |
The closest existing name the field could reference, if one is close. |
Source code in idfkit/exceptions.py
DuplicateObjectError
¶
Bases: IdfKitError
Raised when attempting to add an object with a duplicate name.
Source code in idfkit/exceptions.py
EnergyPlusNotFoundError
¶
Bases: IdfKitError
Raised when EnergyPlus installation cannot be found.
Attributes:
| Name | Type | Description |
|---|---|---|
searched_locations |
The paths that were tried, each once, in the order tried. |
|
requested_version |
The release asked for with |
|
found |
The installations discovery did find, as |
Source code in idfkit/exceptions.py
ExpandObjectsError
¶
Bases: IdfKitError
Raised when an EnergyPlus preprocessor fails.
Attributes:
| Name | Type | Description |
|---|---|---|
preprocessor |
Name of the preprocessor that failed (e.g.
|
|
exit_code |
Process exit code ( |
|
stderr |
Captured standard error output (truncated to 500 chars). |
Source code in idfkit/exceptions.py
FileFormatError
¶
Bases: IDFParseError, ValueError
Raised when a loader is given a file in the other format: epJSON to load_idf, or IDF to load_epjson.
It is a ValueError too, as the json.JSONDecodeError that load_epjson raised for an
IDF file was.
Attributes:
| Name | Type | Description |
|---|---|---|
filepath |
The file that was read. |
|
detected_format |
Literal['idf', 'epjson']
|
The format the file's content is in, |
Source code in idfkit/exceptions.py
FormattingLossWarning
¶
Bases: UserWarning
Warned when save_idf() or save() overwrites a commented IDF file it cannot reproduce.
A document read by load_idf() without preserve_formatting=True keeps no copy of the
file's comments or layout, so writing it back over that file drops every ! comment and
re-sorts the objects. Load with preserve_formatting=True to keep them and change only the
objects you edit, or save to another path. Silence it like any warning:
warnings.filterwarnings("ignore", category=FormattingLossWarning)
Source code in idfkit/exceptions.py
IDFParseError
¶
Bases: IdfKitError
Raised when parsing IDF/epJSON content fails.
Source code in idfkit/exceptions.py
diagnostics = tuple(diagnostics or ())
instance-attribute
¶
IdfKitError
¶
InvalidFieldError
¶
Bases: IdfKitError, AttributeError
Raised when an invalid field is accessed or set.
Inherits from AttributeError so that Python's attribute access
protocol (hasattr, getattr with default) continues to work
correctly when this is raised from __getattr__.
Source code in idfkit/exceptions.py
available_fields = available_fields
instance-attribute
¶
extensible_fields = extensible_fields
instance-attribute
¶
field_name = field_name
instance-attribute
¶
hint = hint
instance-attribute
¶
obj_type = obj_type
instance-attribute
¶
refused = tuple(refused) if refused else ()
instance-attribute
¶
suggestions = _closest_fields(unknown, available_fields or [], hints)
instance-attribute
¶
version = version
instance-attribute
¶
MigrationError
¶
Bases: IdfKitError
Raised when an IDF migration step fails.
Attributes:
| Name | Type | Description |
|---|---|---|
from_version |
Version the failing step started from (if known). |
|
to_version |
Version the failing step targeted (if known). |
|
exit_code |
Process exit code of the transition binary (if available). |
|
stderr |
Captured stderr of the transition binary (truncated to 500 chars). |
|
completed_steps |
Ordered |
|
reason |
The message as given, without the step, the process output or the step count the full message adds, so the error can be re-raised for another step without repeating them. |
Source code in idfkit/exceptions.py
MissingRequiredFieldError
¶
Bases: IdfKitError, AttributeError
Raised when reading a required field that the object does not hold.
A field every EnergyPlus release requires with no default reads as its value type, never
None: add() refuses to create an object without it, and assigning None to it is a
type error. An object can still lack one when it was loaded from a file that omits it, created
with IDFDocument.add(..., validate=False), or cleared through an untyped path. Reading the
field then raises this rather than returning a None the type said could not occur.
It inherits from AttributeError, so getattr(obj, field, None) and hasattr keep
working as the untyped way to ask whether the field is set, as does obj.get(field).
The same holds for a key of an extensible group that every release requires
(vertex_x_coordinate): reading it from a group that lacks it, or snapshotting that group with
as_dict() or as_list(), raises this with wrapper_key and group_index set;
group.get(key) gives None instead.
Attributes:
| Name | Type | Description |
|---|---|---|
obj_type |
The object's type. |
|
obj_name |
The object's name, |
|
field_name |
The field, or the group key, that has no value. |
|
wrapper_key |
The extensible group's wrapper ( |
|
group_index |
The group's 1-based position in the wrapper, or |
Source code in idfkit/exceptions.py
NoDesignDaysError
¶
Bases: IdfKitError
Raised when a DDY file contains no SizingPeriod:DesignDay objects.
This typically occurs for weather stations that lack ASHRAE design conditions data in the climate.onebuilding.org database.
Attributes:
| Name | Type | Description |
|---|---|---|
station_name |
Display name of the station (if available). |
|
ddy_path |
Path to the DDY file that was parsed. |
|
nearby_suggestions |
List of nearby stations that may have design days. |
Source code in idfkit/exceptions.py
ObjectNotFoundError
¶
Bases: IdfKitError, KeyError
Raised when a document has no object of a type by the name looked up.
Raised by doc["Zone"]["name"], doc.rename() and the dotted doc.update(). Inherits
from KeyError so code catching KeyError keeps working; unlike a plain KeyError,
str() gives the message as written, not its repr().
Attributes:
| Name | Type | Description |
|---|---|---|
obj_type |
The object type that was searched. |
|
name |
The name that was not found. |
|
suggestions |
tuple[str, ...]
|
The closest existing names of that type ("did you mean"), closest first. |
available |
tuple[str, ...]
|
The existing names of that type, in document order. |
object_count |
How many objects of that type the document has, named or not, if known. |
Examples:
>>> err = ObjectNotFoundError("Zone", "SPACE1_1", available=["SPACE1-1", "SPACE2-1", "PLENUM-1"])
>>> print(err)
No Zone named 'SPACE1_1'. Did you mean 'SPACE1-1'?
Zone names: SPACE1-1, SPACE2-1, PLENUM-1
>>> isinstance(err, KeyError)
True
Source code in idfkit/exceptions.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
available
property
¶
The existing names of that type, in document order.
message
property
¶
The full message str() gives.
name = name
instance-attribute
¶
obj_type = obj_type
instance-attribute
¶
object_count = object_count
instance-attribute
¶
suggestions
property
¶
The closest existing names of that type ("did you mean"), closest first.
OutputNotFoundError
¶
Bases: IdfKitError, FileNotFoundError
Raised when a simulation result is asked to parse an output file the run did not produce.
Raised by the parsed-output accessors of
SimulationResult (sql, csv, eso,
mtr, html, variables and their async_* counterparts). The message names the
output object to add to the model or, for a failed or refused run, where to read why.
To test for an output without raising, check its path: result.sql_path is None.
Inherits from FileNotFoundError.
Attributes:
| Name | Type | Description |
|---|---|---|
output |
The accessor that found no file, e.g. |
|
run_dir |
The run directory that was searched. |
Source code in idfkit/exceptions.py
ParseDiagnostic
dataclass
¶
One finding from a parse: what happened, and as much location as was available.
There is no severity, and there never has been. Whether a finding stopped the parse is told by
the path it arrives on, IDFParseError.diagnostics for the ones that did and
ParseResult.diagnostics for the ones that did not, rather than by a field on the finding.
code is added last so that every existing positional construction keeps working. It reads
better beside message and is not there, deliberately.
Source code in idfkit/exceptions.py
code = 'ParseError'
class-attribute
instance-attribute
¶
column = None
class-attribute
instance-attribute
¶
filepath = None
class-attribute
instance-attribute
¶
line = None
class-attribute
instance-attribute
¶
message
instance-attribute
¶
obj_name = None
class-attribute
instance-attribute
¶
obj_type = None
class-attribute
instance-attribute
¶
RangeError
¶
Bases: IdfKitError
Raised when a field value is outside the valid range (eppy compatibility).
Attributes:
| Name | Type | Description |
|---|---|---|
obj_type |
The object type. |
|
obj_name |
The object name. |
|
field_name |
The field that failed range checking. |
Source code in idfkit/exceptions.py
RefusedEntry
dataclass
¶
One entry of an IDFObject.update group, or IDFDocument.add call, that will not be applied.
reason is "unknown" (not a field of the type), "name" (renaming has its own
operation), "legacy-flat" (an eppy-style flat extensible name), "non-finite" (a NaN
or infinite value, which no field takes) or "wrapper-value" (the extensible wrapper key
given a value single assignment rejects: not a list, or a list with an item that is not a
dict or group, or a group with an unknown field).
Source code in idfkit/exceptions.py
ResultLookupError
¶
Bases: IdfKitError, KeyError
Raised when a simulation-result lookup finds no output, or several where it needs one.
Raised by SQLResult.get_timeseries,
SQLResult.get_tabular_value,
SQLResult.get_tabular_float,
ESOResult.get_column and
CSVResult.get_column.
Inherits from KeyError so code catching KeyError keeps working; unlike a plain
KeyError, str() gives the message as written, not its repr().
Attributes:
| Name | Type | Description |
|---|---|---|
suggestions |
The closest names the database does have ("did you mean"), closest first. |
|
available |
The keys, frequencies or names that matched or could be passed instead. |
Source code in idfkit/exceptions.py
SchemaNotFoundError
¶
Bases: IdfKitError
Raised when the EpJSON schema file cannot be found.
Source code in idfkit/exceptions.py
SimulationError
¶
Bases: IdfKitError
Raised when an EnergyPlus simulation fails.
Attributes:
| Name | Type | Description |
|---|---|---|
exit_code |
EnergyPlus's exit code, if it ran and exited. |
|
stderr |
Its standard error, if any. |
|
result |
The failed run's result, when raised by
SimulationResult.raise_for_status;
read its |
Source code in idfkit/exceptions.py
UnknownObjectTypeError
¶
Bases: IdfKitError, KeyError
Raised when an unknown object type is encountered.
Inherits from KeyError so that existing code catching KeyError
for missing object types continues to work. Unlike a plain KeyError,
str() gives the message as written, not its repr().
When another bundled release has the type, the message says which releases have it and how to reach one, instead of calling the type unknown.
Attributes:
| Name | Type | Description |
|---|---|---|
obj_type |
The type name that was not found. |
|
version |
The EnergyPlus release it was looked up in, if known. |
|
suggestion |
The closest type name of that release, if one is close. |
Source code in idfkit/exceptions.py
UnknownObjectTypeWarning
¶
Bases: UserWarning
Warned when a document is read by an object type name no bundled EnergyPlus release has.
model["Zoen"] and model.get_collection("Zoen") return an empty collection rather than
raising (see the note on IDFDocument.__getitem__), so a misspelt name would otherwise go
unnoticed. A name some bundled release has, even one the document's own release lacks, is not
warned about. Filter it like any warning:
warnings.filterwarnings("ignore", category=UnknownObjectTypeWarning)
Source code in idfkit/exceptions.py
UnsupportedVersionError
¶
Bases: IdfKitError
Raised when a non-existent EnergyPlus version is requested.
Attributes:
| Name | Type | Description |
|---|---|---|
version |
The requested version tuple. |
|
supported_versions |
Tuple of all supported version tuples. |
Source code in idfkit/exceptions.py
ValidationFailedError
¶
Bases: IdfKitError
Raised when validation fails.
Source code in idfkit/exceptions.py
errors = list(errors)
instance-attribute
¶
VersionMismatchError
¶
Bases: IdfKitError
Raised when an IDF model's version differs from the installed EnergyPlus version.
Carries structured context so callers (including MCP tools and LSP clients) can decide whether to migrate the model or surface the mismatch to the user.
Attributes:
| Name | Type | Description |
|---|---|---|
current |
The model's version tuple. |
|
target |
The installed EnergyPlus version tuple. |
|
migration_chain |
Ordered pairs |
|
direction |
Literal['forward', 'backward']
|
|
Source code in idfkit/exceptions.py
VersionNotFoundError
¶
Bases: IdfKitError
Raised when version cannot be detected from file.
Source code in idfkit/exceptions.py
filepath = filepath
instance-attribute
¶
closest_name(name, candidates)
¶
The candidate closest to name, ignoring case, or None if none is close.
The "did you mean" of the unknown-type and unknown-field errors; see closest_names.
Examples:
>>> closest_name("Zoen", ["Zone", "Material"])
'Zone'
>>> closest_name("ceiling_heigth", ["x_origin", "ceiling_height"])
'ceiling_height'
>>> closest_name("qwerty", ["Zone"]) is None
True
Source code in idfkit/exceptions.py
closest_names(name, candidates, n=1)
¶
Up to n candidates closest to name, ignoring case, closest first.
The one "did you mean" matcher: the unknown-type and unknown-field errors, attribute access
on a document and idfkit check all suggest through it, so they agree on a typo.
Examples:
Source code in idfkit/exceptions.py
format_refused(obj_type, refused, operation='update')
¶
Message for a refused IDFObject.update group or IDFDocument.add call: the type, then one line per entry.