Skip to content

Loading a non-existant file does not raise Exception #11

@atw1020

Description

@atw1020

When attempting to load a non-existent file using MCSchematic, as shown below, MCSchematic does not raise an exception, or warn the user in any other way that they are doing somthing wrong.

schem = mcschematic.MCScematic("/non/existing/file.schem")

Looking into the source, it seems this is an intended feature, as there are if statements checking for file existence.

mcschematic.py:2371

        if type(schematicToLoadPath_or_mcStructure) == str:
            schematicToLoadPath = schematicToLoadPath_or_mcStructure

            if not os.path.isfile(schematicToLoadPath):
                self._defaultInit(); return

            if not schematicToLoadPath.endswith(".schem"):
                self._defaultInit(); return

            self._initFromFile(schematicToLoadPath)

This is extremly user-unfriendly because if you mess up the filepath you're loading, the user isn't informed that they've messed something up. I had a situation where I wanted to load a schematic, modify it, and write it back, and I wasted a ton of time looking for the blocks of the existing schematic and seeing nothing but air.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions