c++ - Error messages and having better organized code in Qt -


when starts loads data file , verify if correct before saving in memory.

repositoryinfile::repositoryinfile(validator *validator){     this->validator = validator;     this->read(); } 

read() private method tries open , read data file. throws exceptions. when catch error in program this:

  try {     //do   } catch (customexception custome) {     qstring message = qstring::fromstdstring(custome.reason());     // i'm not extending std::exception beacause... don't know why     qmessagebox::critical(this, "error!", message);   } 

now, if goes wrong in repositoryinfile's constructor can throw exception , can catch in main function, can't show nice message box on screen informing user went wrong (or don't know how). right show message in console qdebug(), has purpose me.

should redesign way repositoryinfile works , have other method load data file after gui initialized?

not needed. show message box in exception handler. change need make this:

qmessagebox::critical(0, "error!", message); //                    ^ 

so, if replace "zero" become "root" of ui.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -