Skip to content

Commit

Permalink
Use exception for error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
peckto committed Jul 5, 2021
1 parent 52a7921 commit a5acabc
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions app/deepseg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,19 +231,9 @@ class CalcMask final {
size_t height) :
state{thread_state::INIT},
thread{&CalcMask::run, this} {
maskctx = bs_maskgen_new(
modelname,
threads,
width,
height,
nullptr,
onprep,
oninfer,
onmask,
this
);
maskctx = bs_maskgen_new(modelname,threads,width,height,nullptr,onprep,oninfer,onmask,this);
if (!maskctx)
exit(1);
throw "Could not create mask context";

// Do all other initialization …
frame_next = &frame1;
Expand Down Expand Up @@ -277,7 +267,7 @@ class CalcMask final {
}
};

int main(int argc, char* argv[]) {
int main(int argc, char* argv[]) try {

printf("deepseg version %s\n", _STR(DEEPSEG_VERSION));
printf("(c) 2021 by [email protected] & contributors\n");
Expand Down Expand Up @@ -530,7 +520,7 @@ int main(int argc, char* argv[]) {

// timing details..
printf("main [grab:%9ld retr:%9ld copy:%9ld prep:%9ld mask:%9ld post:%9ld v4l2:%9ld FPS: %5.2f] ai: [wait:%9ld prep:%9ld tflt:%9ld mask:%9ld FPS: %5.2f] \e[K\r",
diffnanosecs(ti.grabns, ti.lastns),
diffnanosecs(ti.grabns,ti.lastns),
diffnanosecs(ti.retrns,ti.grabns),
diffnanosecs(ti.copyns,ti.retrns),
diffnanosecs(ti.prepns,ti.copyns),
Expand Down Expand Up @@ -571,4 +561,7 @@ int main(int argc, char* argv[]) {

printf("\n");
return 0;
} catch(const char* msg) {
fprintf(stderr, "Error: %s\n", msg);
return 1;
}

0 comments on commit a5acabc

Please sign in to comment.