bool Configuration::load(const std::string & fileName) { bool result(false); GTRACE(3, "Configuration - loading from " << fileName); std::string fileExtension = stringutil::GetExtensionFromFileName(fileName); // E.g. "ini"; // Use the loader based on the extension. impl_->loader_ptr_.reset(config::LoaderFactory::getPtr()->CreateObject(fileExtension)); //impl_->loader_ptr_ = config::LoaderFactory::getPtr()->CreateObject(fileExtension); if (!impl_->loader_ptr_) { // No loader for this extension! std::string exception_message("Data cannot be loaded using this extension: \""); exception_message.append(fileExtension); exception_message.append("\". No factory detected"); throw guslib::SimpleException(exception_message.c_str()); } result = impl_->loader_ptr_->load(*this, fileName); GTRACE(5, "Configuration - DONE loading from " << fileName); return result; }
void request_complete(ebb_request *request) { ebb_connection *connection = (ebb_connection *)request->data; AsyncConnection *connection_data = (AsyncConnection *)connection->data; connection_data->connection = connection; connection_data->request = request; gettimeofday(&connection_data->starttime, nullptr); connection_data->keep_alive_flag = ebb_request_should_keep_alive(request); ev_async_init(&connection_data->ev_write, write_cb); ev_async_start(connection_data->ev_loop, &connection_data->ev_write); // Try to route to appropriate handler based on path const AbstractRequestHandlerFactory *handler_factory; try { handler_factory = Router::route(connection_data->path); } catch (const RouterException &exc) { std::string exception_message(exc.what()); connection_data->respond("Could not route request, std::exception was: \n" + exception_message); return; } std::shared_ptr<Task> task = handler_factory->create(connection_data); task->setPriority(Task::HIGH_PRIORITY); // give RequestParseTask high priority SharedScheduler::getInstance().getScheduler()->schedule(task); connection_data->waiting_for_response = true; }
int main(){ struct command_t cmd; char input[MAX]; scanf("%[^EOF]s", input); int j; do { int l = strlen(input); for(j = 0; input[j] != '\n'; j++){ cmd.expression[j] = input[j]; } cmd.expression[j] = '\n'; cmd.expression[j + 1] = '\0'; if(exceptions_cmd(&cmd) == 0){ cmd.answer = exec_cmd(&cmd); if(cmd.answer == 42) exception_message(42); else printf("%d\n", cmd.answer); } else{ exception_message(exceptions_cmd(&cmd)); printf("\n"); } j++; if(input[j] == '\0') break; int k; int temp = j; for(k = 0; k < l - temp; k++){ input[k] = input[j]; j++; } input[k] = '\0'; } while(1); return 0; }
/* 例外を投げる関数 */ void exception_sub1() { printf("sub1 start\n"); /* 表示される */ TRY_BEGIN { /* 例外の入れ子 */ exception_sub2(); } CATCH(e) { printf("catch2 %s\n", exception_message(e)); e->end(e); } FINALLY { printf("finally2\n"); /* 表示される */ } TRY_END THROW(expeption_new("100")); printf("sub1 end\n"); /* 表示されない */ }
void request_complete(ebb_request *request) { ebb_connection *connection = (ebb_connection *)request->data; AsyncConnection *connection_data = (AsyncConnection *)connection->data; connection_data->connection = connection; connection_data->request = request; gettimeofday(&connection_data->starttime, nullptr); // Try to route to appropriate handler based on path const AbstractRequestHandlerFactory *handler_factory; try { handler_factory = Router::route(connection_data->path); } catch (const RouterException &exc) { std::string exception_message(exc.what()); connection_data->respond("Could not route request, std::exception was: \n" + exception_message); return; } std::shared_ptr<Task> task = handler_factory->create(connection_data); // Always map the first task to the first core task->setPreferredCore(0); SharedScheduler::getInstance().getScheduler()->schedule(task); }
static bool cal_updatebacking(calentry_t * entry, const char * value) { exception_t * e = NULL; switch (entry->signature) { case T_INTEGER: { int v = parse_int(value, &e); if (!exception_check(&e)) *(int *)entry->backing = v; break; } case T_DOUBLE: { double v = parse_double(value, &e); if (!exception_check(&e)) *(double *)entry->backing = v; break; } default: { LOGK(LOG_ERR, "Unknown calibration entry type %s with sig %c", entry->name, entry->signature); return false; } } if (exception_check(&e)) { LOGK(LOG_ERR, "Could not set calibration entry %s: %s", entry->name, exception_message(e)); exception_free(e); return false; } return true; }
bool vsyscall_exec(const char * name, exception_t ** err, void * ret, va_list args) { // Sanity check if (exception_check(err)) { return false; } const syscall_t * syscall = syscall_get(name); if (syscall == NULL) { exception_set(err, EINVAL, "Syscall %s doesn't exist!", name); return false; } char array[SYSCALL_BUFFERMAX]; { exception_t * e = NULL; ssize_t wrote = vserialize_2array_wheader((void **)array, SYSCALL_BUFFERMAX, &e, method_params(syscall->signature), args); if (wrote <= 0 || exception_check(&e)) { exception_set(err, ENOMEM, "Could not pack '%s' syscall args: %s (SYSCALL_BUFSIZE = %d)", name, exception_message(e), SYSCALL_BUFFERMAX); return false; } } return asyscall_exec(name, err, ret, (void **)array); }
int console_receive(MasterIpcThread* ipcThread, Master* M, ChildProcess* proc, int sourceId, IpcPacket* packet) { ExceptionScope exScope; Console* volatile console = NULL; int volatile ret = false; int ex; exception_begin_try(B(ipcThread), &exScope); switch ((ex = exception_try(B(ipcThread)))) { case Try: ret = console_do_receive(ipcThread, M, proc, sourceId, packet, &console); break; default: if (console) console_destroy(console); log_format(B(ipcThread), LogError, "[console_receive] Error (%i): %s", ex, string_data(exception_message(B(ipcThread)))); exception_handled(B(ipcThread)); break; } exception_end_try(B(ipcThread)); return ret; }