Skip to content

Commit f4984c0

Browse files
ZiuTinyatgineshidalgo99
authored andcommitted
Clean up Unity error logging message (CMU-Perceptual-Computing-Lab#1096)
1 parent e47414a commit f4984c0

File tree

2 files changed

+40
-37
lines changed

2 files changed

+40
-37
lines changed

src/openpose/unity/unityBinding.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace op
8080
}
8181
catch (const std::exception& e)
8282
{
83-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
83+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
8484
}
8585
}
8686

@@ -104,7 +104,7 @@ namespace op
104104
}
105105
catch (const std::exception& e)
106106
{
107-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
107+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
108108
}
109109
}
110110

@@ -124,7 +124,7 @@ namespace op
124124
}
125125
catch (const std::exception& e)
126126
{
127-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
127+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
128128
}
129129
}
130130

@@ -144,7 +144,7 @@ namespace op
144144
}
145145
catch (const std::exception& e)
146146
{
147-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
147+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
148148
}
149149
}
150150

@@ -164,7 +164,7 @@ namespace op
164164
}
165165
catch (const std::exception& e)
166166
{
167-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
167+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
168168
}
169169
}
170170

@@ -184,7 +184,7 @@ namespace op
184184
}
185185
catch (const std::exception& e)
186186
{
187-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
187+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
188188
}
189189
}
190190

@@ -204,7 +204,7 @@ namespace op
204204
}
205205
catch (const std::exception& e)
206206
{
207-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
207+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
208208
}
209209
}
210210

@@ -226,7 +226,7 @@ namespace op
226226
}
227227
catch (const std::exception& e)
228228
{
229-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
229+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
230230
}
231231
}
232232

@@ -252,7 +252,7 @@ namespace op
252252
}
253253
catch (const std::exception& e)
254254
{
255-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
255+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
256256
}
257257
}
258258

@@ -272,7 +272,7 @@ namespace op
272272
}
273273
catch (const std::exception& e)
274274
{
275-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
275+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
276276
}
277277
}
278278

@@ -292,7 +292,7 @@ namespace op
292292
}
293293
catch (const std::exception& e)
294294
{
295-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
295+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
296296
}
297297
}
298298

@@ -323,7 +323,7 @@ namespace op
323323
}
324324
catch (const std::exception& e)
325325
{
326-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
326+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
327327
}
328328
}
329329

@@ -343,7 +343,7 @@ namespace op
343343
}
344344
catch (const std::exception& e)
345345
{
346-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
346+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
347347
}
348348
}
349349

@@ -363,7 +363,7 @@ namespace op
363363
}
364364
catch (const std::exception& e)
365365
{
366-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
366+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
367367
}
368368
}
369369

@@ -382,7 +382,7 @@ namespace op
382382
}
383383
catch (const std::exception& e)
384384
{
385-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
385+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
386386
}
387387
}
388388

@@ -394,7 +394,7 @@ namespace op
394394
}
395395
catch (const std::exception& e)
396396
{
397-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
397+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
398398
}
399399
}
400400
};
@@ -450,7 +450,7 @@ namespace op
450450
}
451451
catch (const std::exception& e)
452452
{
453-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
453+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
454454
}
455455
}
456456

@@ -465,7 +465,7 @@ namespace op
465465
}
466466
catch (const std::exception& e)
467467
{
468-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
468+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
469469
}
470470
}
471471

@@ -482,7 +482,7 @@ namespace op
482482
}
483483
catch (const std::exception& e)
484484
{
485-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
485+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
486486
}
487487
}
488488

@@ -496,7 +496,7 @@ namespace op
496496
}
497497
catch (const std::exception& e)
498498
{
499-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
499+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
500500
}
501501
}
502502
#endif
@@ -510,7 +510,7 @@ namespace op
510510
}
511511
catch (const std::exception& e)
512512
{
513-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
513+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
514514
}
515515
}
516516

@@ -523,7 +523,7 @@ namespace op
523523
}
524524
catch (const std::exception& e)
525525
{
526-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
526+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
527527
}
528528
}
529529

@@ -558,7 +558,7 @@ namespace op
558558
}
559559
catch (const std::exception& e)
560560
{
561-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
561+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
562562
}
563563
}
564564

@@ -576,7 +576,7 @@ namespace op
576576
}
577577
catch (const std::exception& e)
578578
{
579-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
579+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
580580
}
581581
}
582582

@@ -594,7 +594,7 @@ namespace op
594594
}
595595
catch (const std::exception& e)
596596
{
597-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
597+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
598598
}
599599
}
600600

@@ -609,7 +609,7 @@ namespace op
609609
}
610610
catch (const std::exception& e)
611611
{
612-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
612+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
613613
}
614614
}
615615

@@ -630,7 +630,7 @@ namespace op
630630
}
631631
catch (const std::exception& e)
632632
{
633-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
633+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
634634
}
635635
}
636636

@@ -651,7 +651,7 @@ namespace op
651651
}
652652
catch (const std::exception& e)
653653
{
654-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
654+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
655655
}
656656
}
657657

@@ -666,7 +666,7 @@ namespace op
666666
}
667667
catch (const std::exception& e)
668668
{
669-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
669+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
670670
}
671671
}
672672

@@ -683,7 +683,7 @@ namespace op
683683
}
684684
catch (const std::exception& e)
685685
{
686-
log(e.what(), Priority::Max, __LINE__, __FUNCTION__, __FILE__);
686+
errorDestructor(e.what(), __LINE__, __FUNCTION__, __FILE__);
687687
}
688688
}
689689
}

src/openpose/utilities/errorAndLog.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ namespace op
190190
errorMessageToPrint = errorEnum + errorThreadLine + "\n" + errorMessageToPrint;
191191
}
192192
else if (errorMode == 3)
193-
errorMessageToPrint += "\n" + errorEnum + "[Error occurred in a destructor, so no std::exception"
194-
" has been thrown. Returning with exit status 0]";
193+
errorMessageToPrint += "\n" + errorEnum + "[Error occurred in a destructor or in the OpenPose"
194+
" Unity Plugin, so no std::exception has been thrown. Returning with exit status 0]";
195195
errorMessageToPropagate = createFullMessage(message) + errorMessageToPrint + "\n";
196196
if (errorMode == 1)
197197
{
@@ -214,11 +214,6 @@ namespace op
214214
if (checkIfErrorHas(ErrorMode::FileLogging))
215215
fileLogging(errorMessageToPrint);
216216

217-
// Unity logError
218-
#ifdef USE_UNITY_SUPPORT
219-
UnityDebugger::logError(errorMessageToPrint);
220-
#endif
221-
222217
// std::runtime_error
223218
if (errorMode == 1)
224219
{
@@ -227,8 +222,16 @@ namespace op
227222
sThreadErrorMessages.emplace_back(errorMessageToPropagate);
228223
}
229224
else
225+
{
226+
// Unity logError
227+
#ifdef USE_UNITY_SUPPORT
228+
if (errorMode == 3)
229+
UnityDebugger::logError(errorMessageToPropagate);
230+
#endif
231+
230232
if (checkIfErrorHas(ErrorMode::StdRuntimeError) && errorMode != 3)
231233
throw std::runtime_error{errorMessageToPropagate};
234+
}
232235
}
233236

234237

0 commit comments

Comments
 (0)