AxisClientException::AxisClientException() { /* This only serves the pupose of indicating that the * service has thrown an excpetion */ m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION; processException(m_iExceptionCode); }
int main(int argc, char** argv) { print("aa000"); try { foo(); bar(); } catch (...) { processException(); } std::bind(l, 1, 2)(); //后台完成执行 std::async(l, 3, 44); return 0; }
// --------------------------------------------------------------------- //! Generate a message string about the exception. // --------------------------------------------------------------------- void ExceptionMessageGenerator::GetMessageString( Exception* ex, //!< exception object MBCString& message //!< OUTPUT. a message is returned. ) const { try { message.Empty(); try { processException(ex, message); } catch (Exception* ex2) { ex2->Delete(); message.Empty(); } if (message.IsEmpty()) { try { message = stringLoader->LoadNativeString(NSID_EMSG_GENERIC); } catch (Exception* ex3) { ex3->Delete(); message = ALITERAL("An error has occurred."); } ConstAStr errorMessage = ex->GetErrorMessage(); if (NULL != errorMessage && ALITERAL('\0') != errorMessage[0]) { message += ALITERAL("\n"); message += errorMessage; } } } catch (Exception* ex4) { ex4->Delete(); } }
int main() { try { // zwei Strings anlegen std::string vorname("bjarne"); // kann std::bad_alloc auslösen std::string nachname("stroustrup"); // kann std::bad_alloc auslösen std::string name; // Strings manipulieren vorname.at(20) = 'B'; // löst std::out_of_range aus nachname[30] = 'S'; // FEHLER: undefiniertes Verhalten // Strings verketten name = vorname + " " + nachname; // könnte std::bad_alloc auslösen } catch (...) { // alle Ausnahmen in Hilfsfunktion behandeln processException(); return EXIT_FAILURE; // main() mit Fehlerstatus beenden } std::cout << "OK, bisher ging alles gut" << std::endl; }
int main() { try { // create two strings std::string firstname("bjarne"); // may trigger std::bad_alloc std::string lastname("stroustrup"); // may trigger std::bad_alloc std::string name; // manipulate strings firstname.at(20) = 'B'; // triggers std::out_of_range lastname[30] = 'S'; // ERROR: undefined behaviour // chain strings name = firstname + " " + lastname; // may trigger std::bad_alloc } catch (...) { // deal with all exceptions in auxiliary function processException(); return EXIT_FAILURE; // exit main() with error status } std::cout << "OK, everything was alright up until now" << std::endl; }
int main(int argc, char * argv []) { /* Create first pipe between Generator() and the first Sieve() */ int_t thread_ID = 0; channels[thread_ID] = new channel (); /* Start number generator */ sem_t sem_bfr; sem_init(& sem_bfr, 0, NUMBERS_IN_PIPE); sem_buffers.push_back(& sem_bfr); sem_t sem_nmb; sem_init(&sem_nmb, 0, 0); sem_numbers.push_back(& sem_nmb); channels[thread_ID]->setSemaphores(sem_bfr, sem_nmb); int ret = pthread_create (& threads[thread_ID], NULL, genNumbers, channels[thread_ID]); if (ret < 0) perror ("pthread_create (& pids[0], NULL, GenNumbers, & ppwr)"); pthread_mutex_lock (&mtx_threads_count); threads_count ++; pthread_mutex_unlock (&mtx_threads_count); /* Start sieve()s in treads */ int read_bytes (0); while (threads_count) { if (threads_count >= MAX_NUMBER_OF_THREADS) { usleep (5); } else { int_t newPrime = channels[thread_ID]->receiveMessage(read_bytes); if (! newPrime) { pthread_mutex_lock (&mtx_printf); printf("\nnewPrime = 0: %d, ID: %d, count of threads: %d\n",newPrime, thread_ID, threads_count); pthread_mutex_unlock (&mtx_printf); return EXIT_SUCCESS; } primes.push_back(newPrime); thread_ID ++; channels[thread_ID] = new channel(thread_ID); channels[thread_ID]->setPrime(newPrime); sem_t sem_bfr; sem_init(& sem_bfr, 0, NUMBERS_IN_PIPE); sem_buffers.push_back(& sem_bfr); sem_t sem_nmb; sem_init(&sem_nmb, 0, 0); sem_numbers.push_back(& sem_nmb); channels[thread_ID]->setSemaphores(sem_bfr, sem_nmb); pthread_mutex_lock (&mtx_printf); printf("\nNew filter: %d, ID: %d, count of threads: %d",newPrime, thread_ID, threads_count); pthread_mutex_unlock (&mtx_printf); try { int ret = pthread_create (& threads[thread_ID], NULL, sieveCell, channels[thread_ID]); if (ret < 0) perror ("pthread_create: "); } catch (...) { processException(); } pthread_mutex_lock (&mtx_threads_count); threads_count ++; pthread_mutex_unlock (&mtx_threads_count); } } /* wait for all threads */ for (int_t i = 0; i < MAX_NUMBER_OF_THREADS-1; ++ i) if (threads[i]) { int join = pthread_join(threads[i], NULL); if ( join ) perror ("pthread_join(Primes[0]->m_pthread, NULL)"); } for (int_t i = 0; i < MAX_NUMBER_OF_THREADS -1; i ++) channels[i]->destroy(); return 0; }
void * sieveCell (void * arg) { // take arguments from *args int_t myID = ((channel *) arg)->getID(); usleep(5); int_t my_prime = 0; try { my_prime = channels[myID]->getPrime(); } catch (...) { processException(); } if (! my_prime) { perror("void * sieveCell (void * arg) { my_prime }"); my_prime = channels[myID]->getPrime(); } int pp_read = 0; int pp_write = 0; pp_read = channels[myID-1]->getPipeRead(); pp_write = channels[myID]->getPipeWrite(); if (pp_read == 0) perror ("pp_read == 0"); if (pp_write == 0) perror ("pp_write == 0"); int_t number (0); int read_bytes = sizeof(int_t); do { number = channels[myID-1]->receiveMessage(read_bytes); usleep (10); // pthread_mutex_lock (&mtx_printf); // pthread_mutex_unlock (&mtx_printf); if (number != END_OF_NUMBERS) { if (number % my_prime) { usleep(10); channels[myID]->sendMessage(number); } } } while ( (number != END_OF_NUMBERS) ); //if (number == END_OF_NUMBERS) { channels[myID]->sendMessage(END_OF_NUMBERS); pthread_mutex_lock (&mtx_printf); printf ("\nChannel[ %d ]: destroy(), count of threads: %d", myID-1, threads_count); pthread_mutex_unlock (&mtx_printf); while ((myID-1) != min_number_of_thread) { usleep(5); } if ((myID-1) == min_number_of_thread) { pthread_mutex_lock (&mtx_min_number_of_thread); channels[myID-1]->destroy(); min_number_of_thread ++; pthread_mutex_unlock (&mtx_min_number_of_thread); } pthread_mutex_lock (&mtx_threads_count); threads_count --; pthread_mutex_unlock (&mtx_threads_count); } return 0; }
AxisClientException::AxisClientException(exception* e,int iExceptionCode) { processException (e, iExceptionCode); }
AxisClientException::AxisClientException(exception* e) { processException (e); }
AxisClientException::AxisClientException(int iExceptionCode) { m_iExceptionCode = iExceptionCode; processException (iExceptionCode); }
AxisClientException::AxisClientException(ISoapFault* pFault) { m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION; processException(pFault);}