void throw_from_rcl_error( rcl_ret_t ret, const std::string & prefix, const rcl_error_state_t * error_state, void (*reset_error)()) { if (RCL_RET_OK == ret) { throw std::invalid_argument("ret is RCL_RET_OK"); } if (!error_state) { error_state = rcl_get_error_state(); } if (!error_state) { throw std::runtime_error("rcl error state is not set"); } std::string formated_prefix = prefix; if (!prefix.empty()) { formated_prefix += ": "; } RCLErrorBase base_exc(ret, error_state); if (reset_error) { reset_error(); } switch (ret) { case RCL_RET_BAD_ALLOC: throw RCLBadAlloc(base_exc); case RCL_RET_INVALID_ARGUMENT: throw RCLInvalidArgument(base_exc, formated_prefix); default: throw RCLError(base_exc, formated_prefix); } }
static int msfs_create(const char * path, mode_t mode, struct fuse_file_info * fi) { printf("msfs_create(%s), mode: %u\n", path, mode); reset_error(); inode_t inode = create_inode_from_path(path, mode); if(msfs_error != 0) return msfs_error; fi->fh = inode.attributes.st_ino; return msfs_error; }
static int msfs_getattr(const char *path, struct stat *stbuf) { printf("msfs_getattr(%s)\n", path); reset_error(); inode_t inode = inode_from_path(path); if(msfs_error != 0) return msfs_error; *stbuf = inode.attributes; printf("msfs_getattr(%s), found.\n", path); return 0; }
static int msfs_ftruncate(const char * path, off_t off, struct fuse_file_info * fi) { printf("msfs_ftruncate(%s)\n", path); reset_error(); inode_t inode = read_inode((addr_t)fi->fh); if(msfs_error != 0) return msfs_error; if(!check_access(&inode, O_TRUNC)) return -EPERM; inode.attributes.st_size = (addr_t) off; write_inode(&inode); return msfs_error; }
static int msfs_write(const char *path, const char *data, size_t size, off_t offset, fuse_file_info *fi) { printf("msfs_write(%s)\n", path); reset_error(); inode_t inode = read_inode((addr_t)fi->fh); if(msfs_error != 0) return msfs_error; int bytes = write_inode_data(&inode, offset, size, data); if(msfs_error != 0) return msfs_error; return bytes; }
static int msfs_opendir(const char * path, fuse_file_info * fi) { printf("msfs_opendir(%s)\n", path); reset_error(); inode_t inode = inode_from_path(path); if(msfs_error != 0) return msfs_error; if(!is_directory(&inode)) return -ENOTDIR; if(!check_access(&inode, fi->flags)) return -EPERM; fi->fh = (uint64_t) inode.attributes.st_ino; printf("msfs_opendir(%s) found inode %lu\n", path, inode.attributes.st_ino); return 0; }
static int msfs_open(const char *path, fuse_file_info *fi) { printf("msfs_open(%s)\n", path); reset_error(); inode_t inode = inode_from_path(path); if(msfs_error != 0) return msfs_error; if(is_directory(&inode)) return -EISDIR; if(!check_access(&inode, fi->flags)) return -EPERM; printf("Lock owner: %lu\n", fi->lock_owner); fi->fh = (uint64_t) inode.attributes.st_ino; return msfs_error; }
static int msfs_read(const char *path, char *buf, size_t size, off_t offset, fuse_file_info *fi) { printf("msfs_read(%s)\n", path); reset_error(); inode_t inode = read_inode((addr_t)fi->fh); if(msfs_error != 0) return msfs_error; bump_atime(&inode); int bytes = read_inode_data(&inode, offset, size, buf); if(msfs_error != 0) return msfs_error; return bytes; }
bool MinecraftDynmapProto::handleError(const std::string &method, const std::string &error, bool force_disconnect) { increment_error(); debugLogA("!!!!! Quitting %s() with error: %s", method.c_str(), !error.empty() ? error.c_str() : "Something went wrong"); if (!force_disconnect && error_count_ <= (UINT)db_get_b(NULL, m_szModuleName, MINECRAFTDYNMAP_KEY_TIMEOUTS_LIMIT, MINECRAFTDYNMAP_TIMEOUTS_LIMIT)) { return true; } reset_error(); SetStatus(ID_STATUS_OFFLINE); return false; }
void tester_util::reset() { try { m_tmpdir = bunsan::tempfile::directory_in_directory(m_container_testing_root); m_current_root = m_container->filesystem().containerPath(m_tmpdir.path()); m_container->filesystem().setOwnerId(m_current_root, {0, 0}); m_container->filesystem().setMode(m_current_root, 0500); m_process_group = m_container->createProcessGroup(); m_receive.clear(); m_test_files.clear(); m_solution_files.clear(); m_container_solution_files.clear(); } catch (std::exception &) { BOOST_THROW_EXCEPTION(reset_error() << bunsan::enable_nested_current()); } }
bool facebook_client::handle_error(std::string method, int action) { increment_error(); parent->debugLogA("!!!!! %s(): Something with Facebook went wrong", method.c_str()); bool result = (error_count_ <= (UINT)parent->getByte(FACEBOOK_KEY_TIMEOUTS_LIMIT, FACEBOOK_TIMEOUTS_LIMIT)); if (action == FORCE_DISCONNECT || action == FORCE_QUIT) result = false; if (!result) { reset_error(); if (action != FORCE_QUIT) parent->SetStatus(ID_STATUS_OFFLINE); } return result; }
static int msfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, fuse_file_info *fi) { reset_error(); printf("msfs_readdir(%s) inode %lu\n", path, fi->fh); inode_t entry_inode, inode = read_inode((addr_t)fi->fh); if(msfs_error != 0) return msfs_error; bump_atime(&inode); addr_t addr = 0; file_entry_t * entry; entry = next_file_entry(&inode, &addr); while(entry != NULL) { entry_inode = read_inode(entry->address); filler(buf, entry->name, &entry_inode.attributes, 0); free_file_entry(entry); entry = next_file_entry(&inode, &addr); } return msfs_error; }
bool facebook_client::handle_error( std::string method, bool force_disconnect ) { bool result; increment_error(); parent->Log("!!!!! %s(): Something with Facebook went wrong", method.c_str()); if ( force_disconnect ) result = false; else if ( error_count_ <= (UINT)DBGetContactSettingByte(NULL,parent->m_szModuleName,FACEBOOK_KEY_TIMEOUTS_LIMIT,FACEBOOK_TIMEOUTS_LIMIT)) result = true; else result = false; if ( result == false ) { reset_error(); parent->SetStatus(ID_STATUS_OFFLINE); } return result; }
bool Omegle_client::handle_error( std::string method, bool force_disconnect ) { bool result; increment_error(); parent->debugLogA("!!!!! %s(): Something with Omegle went wrong", method.c_str()); if ( force_disconnect ) result = false; else if ( error_count_ <= (UINT)db_get_b(NULL,parent->m_szModuleName,OMEGLE_KEY_TIMEOUTS_LIMIT,OMEGLE_TIMEOUTS_LIMIT)) result = true; else result = false; if ( result == false ) { reset_error(); parent->UpdateChat(NULL, TranslateT("Connection error.")); parent->StopChat(false); } return result; }
int Ndb_move_data::move_data(Ndb* ndb) { int ret = 0; Op& op = m_op; Stat& stat = m_stat; stat.rows_moved = 0; // keep rows_total do { const NDB_TICKS now = NdbTick_getCurrentTicks(); ndb_srand((unsigned)now.getUint64()); reset_error(); CHK2(m_source != 0 && m_target != 0, (Error::InvalidState, "source / target not defined")); op.ndb = ndb; CHK1(m_error.code == 0); CHK1(check_tables() == 0); CHK1(start_scan() == 0); while (1) { CHK1(move_batch() == 0); stat.rows_moved += op.rows_in_batch; stat.rows_total += op.rows_in_batch; stat.truncated += op.truncated_in_batch; require(op.end_of_scan == (op.rows_in_batch == 0)); if (op.end_of_scan) break; } CHK1(ret == 0); } while (0); close_op(ndb, ret); return ret; }
static int msfs_mkdir(const char * path, mode_t mode) { reset_error(); create_inode_from_path(path, mode | S_IFDIR); if(msfs_error != 0) return msfs_error; return msfs_error; }
static int msfs_rename(const char * from, const char * to) { reset_error(); rename_file(from, to); return msfs_error; }
static void msfs_destroy(void * ptr) { reset_error(); cleanup(); }
bool Omegle_client::handle_success( std::string method ) { parent->debugLogA(" << Quitting %s()", method.c_str()); reset_error(); return true; }
bool facebook_client::handle_success( std::string method ) { parent->Log(" << Quitting %s()", method.c_str()); reset_error(); return true; }
static int msfs_rmdir ( const char * path) { reset_error(); file_entry_t * entry = find_entry(path); return msfs_rm(entry, 1); }
bool MinecraftDynmapProto::handleSuccess(const std::string &method) { debugLogA(" << Quitting %s()", method.c_str()); reset_error(); return true; }