Skip to content

Commit c17a9f9

Browse files
committed
MIES_MassExperimentProcessing.ipf: Enhance error handling
Now that we can potentially create multiple NWB files per device we also need to cleanup the per-device NWB file in case of error. Also add missing AssertOnAndClearRTError() before the try/catch loops.
1 parent 416f622 commit c17a9f9

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Packages/Conversion/MIES_MassExperimentProcessing.ipf

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,13 @@ static Function ProcessCurrentExperiment(STRUCT MultiExperimentProcessPrefs &pre
107107
DoWindow/K HistoryCarbonCopy
108108
NewNotebook/V=0/F=0/N=HistoryCarbonCopy
109109

110+
AssertOnAndClearRTError()
110111
try
111112
PerformMiesTasks(outputFilePath); AbortOnRTE
112113
catch
113-
ClearRTError()
114-
print "Caught an RTE"
114+
printf "Caught an RTE or abort: V_AbortCode=%d\r", V_AbortCode
115115
JSON_AddBoolean(jsonID, "/log/" + num2str(index) + "/error", 1)
116116
JSON_SetVariable(jsonID, "/errors", JSON_GetVariable(jsonID, "/errors") + 1)
117-
HDF5CloseFile/A/Z 0
118-
DeleteFile/Z outputFilePath
119117
endtry
120118

121119
Notebook HistoryCarbonCopy, getData=1
@@ -134,7 +132,7 @@ End
134132
static Function PerformMiesTasks(string outputFilePath)
135133

136134
string folder, message, devSuffix, outputFilePathWithDevSuffix
137-
variable error
135+
variable error, doAbort
138136

139137
printf "Free Memory: %g GB\r", GetFreeMemory()
140138

@@ -144,21 +142,27 @@ static Function PerformMiesTasks(string outputFilePath)
144142
CreateFolderOnDisk(folder)
145143
endif
146144

147-
ClearRTError()
148-
149145
WAVE/T devicesWithContent = ListToTextWave(GetAllDevicesWithContent(contentType = CONTENT_TYPE_ALL), ";")
150146

151147
for(device : devicesWithContent)
152148
devSuffix = SelectString(DimSize(devicesWithContent, ROWS) > 1, "", NWB_GetFileNameSuffixDevice(device))
153149
outputFilePathWithDevSuffix = RemoveEnding(outputFilePath, NWB_FILE_SUFFIX) + devSuffix + NWB_FILE_SUFFIX
154150

155-
NWB_ExportAllData(NWB_VERSION_LATEST, overrideFullFilePath = outputFilePathWithDevSuffix, device = device)
156-
HDF5CloseFile/A/Z 0
151+
AssertOnAndClearRTError()
152+
try
153+
NWB_ExportAllData(NWB_VERSION_LATEST, overrideFullFilePath = outputFilePathWithDevSuffix, device = device); AbortOnRTE
154+
catch
155+
HDF5CloseFile/A/Z 0
156+
DeleteFile/Z outputFilePath
157+
doAbort = 1
158+
endtry
159+
160+
message = GetRTErrMessage()
161+
error = ClearRTError()
162+
ASSERT(error == 0, "Encountered lingering RTE of " + num2str(error) + "(message: " + message + ") after executing NWB_ExportAllData.")
157163
endfor
158164

159-
message = GetRTErrMessage()
160-
error = GetRTError(1)
161-
ASSERT(error == 0, "Encountered lingering RTE of " + num2str(error) + "(message: " + message + ") after executing NWB_ExportAllData.")
165+
ASSERT(doAbort == 0, "Encountered abort")
162166
End
163167

164168
static Function IsAppropriateExperiment()

0 commit comments

Comments
 (0)