added some more specifc error codes.

This commit is contained in:
suter_a 2019-04-25 20:23:40 +02:00
parent 9d12700f39
commit 96d9ba5f88

View File

@ -98,6 +98,7 @@ void musrview_syntax()
*/ */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int result = PMUSR_SUCCESS;
bool show_syntax = false; bool show_syntax = false;
int status; int status;
bool success = true; bool success = true;
@ -119,7 +120,7 @@ int main(int argc, char *argv[])
// check input arguments // check input arguments
if (argc == 1) { if (argc == 1) {
musrview_syntax(); musrview_syntax();
return PMUSR_SUCCESS; return PMUSR_SYNTAX_REQUEST;
} }
for (int i=1; i<argc; i++) { for (int i=1; i<argc; i++) {
if (strstr(argv[i], ".msr") || strstr(argv[i], ".mlog")) { if (strstr(argv[i], ".msr") || strstr(argv[i], ".mlog")) {
@ -272,11 +273,12 @@ int main(int argc, char *argv[])
success = dataHandler->IsAllDataAvailable(); success = dataHandler->IsAllDataAvailable();
if (!success) { if (!success) {
std::cerr << std::endl << ">> musrview **ERROR** Couldn't read all data files, will quit ..." << std::endl; std::cerr << std::endl << ">> musrview **ERROR** Couldn't read all data files, will quit ..." << std::endl;
result = PMUSR_DATA_FILE_READ_ERROR;
} }
// generate the necessary histogramms for the view // generate the necessary histogramms for the view
PRunListCollection *runListCollection = nullptr; PRunListCollection *runListCollection = nullptr;
if (success) { if (result == PMUSR_SUCCESS) {
// feed all the necessary histogramms for the view // feed all the necessary histogramms for the view
runListCollection = new PRunListCollection(msrHandler, dataHandler); runListCollection = new PRunListCollection(msrHandler, dataHandler);
for (unsigned int i=0; i<msrHandler->GetMsrRunList()->size(); i++) { for (unsigned int i=0; i<msrHandler->GetMsrRunList()->size(); i++) {
@ -293,13 +295,14 @@ int main(int argc, char *argv[])
if (!success) { if (!success) {
std::cerr << std::endl << ">> musrview **ERROR** Couldn't handle run no " << i << " "; std::cerr << std::endl << ">> musrview **ERROR** Couldn't handle run no " << i << " ";
std::cerr << (*msrHandler->GetMsrRunList())[i].GetRunName()->Data(); std::cerr << (*msrHandler->GetMsrRunList())[i].GetRunName()->Data();
result = PMUSR_MSR_RUN_ERROR;
break; break;
} }
} }
} }
} }
if (success) { if (result == PMUSR_SUCCESS) {
// generate Root application needed for PMusrCanvas // generate Root application needed for PMusrCanvas
if (graphicsOutput || asciiOutput) { if (graphicsOutput || asciiOutput) {
argv[argc] = (char*)malloc(16*sizeof(char)); argv[argc] = (char*)malloc(16*sizeof(char));
@ -409,5 +412,5 @@ int main(int argc, char *argv[])
runListCollection = nullptr; runListCollection = nullptr;
} }
return PMUSR_SUCCESS; return result;
} }