Skip to content

Commit fabbb04

Browse files
authored
Write errors to log if generateJsonFile fails (#36)
1 parent 71733fe commit fabbb04

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

_validate/createJson.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -213,18 +213,30 @@ def main():
213213
errorFile.write(f"Validation Errors:\n{manifest.errors}")
214214
raise ValueError(f"Invalid manifest file: {manifest.errors}")
215215

216-
generateJsonFile(
217-
manifest=manifest,
218-
addonPath=args.file,
219-
parentDir=args.parentDir,
220-
channel=args.channel,
221-
publisher=args.publisher,
222-
sourceUrl=args.sourceUrl,
223-
url=args.url,
224-
licenseName=args.licenseName,
225-
# Convert the case --licUrl='' to --licUrl=None
226-
licenseUrl=args.licenseUrl if args.licenseUrl else None,
227-
)
216+
try:
217+
generateJsonFile(
218+
manifest=manifest,
219+
addonPath=args.file,
220+
parentDir=args.parentDir,
221+
channel=args.channel,
222+
publisher=args.publisher,
223+
sourceUrl=args.sourceUrl,
224+
url=args.url,
225+
licenseName=args.licenseName,
226+
# Convert the case --licUrl='' to --licUrl=None
227+
licenseUrl=args.licenseUrl if args.licenseUrl else None,
228+
)
229+
except Exception as e:
230+
if manifest.errors:
231+
if errorFilePath:
232+
with open(errorFilePath, "w") as errorFile:
233+
errorFile.write(f"Validation Errors:\n{manifest.errors}")
234+
raise ValueError(f"Invalid manifest file: {manifest.errors}")
235+
else:
236+
if errorFilePath:
237+
with open(errorFilePath, "w") as errorFile:
238+
errorFile.write(f"Validation Errors:\n{e}")
239+
raise
228240

229241

230242
if __name__ == '__main__':

0 commit comments

Comments
 (0)