Skip to content

Commit

Permalink
ModuleObj - More descriptive error message if objects directory doesn…
Browse files Browse the repository at this point in the history
…'t exist
  • Loading branch information
Deline committed Aug 21, 2024
1 parent 70648ca commit 901e07b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bifacial_radiance/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,14 @@ def _saveModule(self, savedata, json=True, rewriteModulefile=True):

if not os.path.isfile(self.modulefile):
# py2 and 3 compatible: binary write, encode text first
with open(self.modulefile, 'wb') as f:
f.write(self.text.encode('ascii'))
try:
with open(self.modulefile, 'wb') as f:
f.write(self.text.encode('ascii'))
except FileNotFoundError:
raise Exception(f'ModuleObj Error: directory "\{os.path.dirname(self.modulefile)}" not found '\
f' in current path which is {os.getcwd()}. Cannot create '\
f'{os.path.basename(self.modulefile)}. '\
'Are you in a valid bifacial_radiance directory?')

def showModule(self):
"""
Expand Down

0 comments on commit 901e07b

Please sign in to comment.