Skip to content

Commit

Permalink
Exceptions fixups (#82)
Browse files Browse the repository at this point in the history
* inline exceptions

* use throw statement rather than function
  • Loading branch information
mikaelarguedas authored Feb 14, 2018
1 parent 8a0f6c3 commit ab207e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions include/class_loader/class_loader_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ Base * createInstance(const std::string & derived_class_name, ClassLoader * load

obj = factory->create();
} else {
throw(class_loader::CreateClassException(
"Could not create instance of type " + derived_class_name));
throw class_loader::CreateClassException(
"Could not create instance of type " + derived_class_name);
}
}

Expand Down
10 changes: 5 additions & 5 deletions include/class_loader/class_loader_exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace class_loader
class ClassLoaderException : public std::runtime_error
{
public:
explicit ClassLoaderException(const std::string error_desc)
explicit inline ClassLoaderException(const std::string error_desc)
: std::runtime_error(error_desc) {}
};

Expand All @@ -54,7 +54,7 @@ class ClassLoaderException : public std::runtime_error
class LibraryLoadException : public ClassLoaderException
{
public:
explicit LibraryLoadException(const std::string error_desc)
explicit inline LibraryLoadException(const std::string error_desc)
: ClassLoaderException(error_desc) {}
};

Expand All @@ -65,7 +65,7 @@ class LibraryLoadException : public ClassLoaderException
class LibraryUnloadException : public ClassLoaderException
{
public:
explicit LibraryUnloadException(const std::string error_desc)
explicit inline LibraryUnloadException(const std::string error_desc)
: ClassLoaderException(error_desc) {}
};

Expand All @@ -76,7 +76,7 @@ class LibraryUnloadException : public ClassLoaderException
class CreateClassException : public ClassLoaderException
{
public:
explicit CreateClassException(const std::string error_desc)
explicit inline CreateClassException(const std::string error_desc)
: ClassLoaderException(error_desc) {}
};

Expand All @@ -87,7 +87,7 @@ class CreateClassException : public ClassLoaderException
class NoClassLoaderExistsException : public ClassLoaderException
{
public:
explicit NoClassLoaderExistsException(const std::string error_desc)
explicit inline NoClassLoaderExistsException(const std::string error_desc)
: ClassLoaderException(error_desc) {}
};

Expand Down
20 changes: 10 additions & 10 deletions src/class_loader_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,18 +451,18 @@ void loadLibrary(const std::string & library_path, ClassLoader * loader)
} catch (const Poco::LibraryLoadException & e) {
setCurrentlyLoadingLibraryName("");
setCurrentlyActiveClassLoader(nullptr);
throw(class_loader::LibraryLoadException(
"Could not load library (Poco exception = " + std::string(e.message()) + ")"));
throw class_loader::LibraryLoadException(
"Could not load library (Poco exception = " + std::string(e.message()) + ")");
} catch (const Poco::LibraryAlreadyLoadedException & e) {
setCurrentlyLoadingLibraryName("");
setCurrentlyActiveClassLoader(nullptr);
throw(class_loader::LibraryLoadException(
"Library already loaded (Poco exception = " + std::string(e.message()) + ")"));
throw class_loader::LibraryLoadException(
"Library already loaded (Poco exception = " + std::string(e.message()) + ")");
} catch (const Poco::NotFoundException & e) {
setCurrentlyLoadingLibraryName("");
setCurrentlyActiveClassLoader(nullptr);
throw(class_loader::LibraryLoadException(
"Library not found (Poco exception = " + std::string(e.message()) + ")"));
throw class_loader::LibraryLoadException(
"Library not found (Poco exception = " + std::string(e.message()) + ")");
}

setCurrentlyLoadingLibraryName("");
Expand Down Expand Up @@ -549,12 +549,12 @@ void unloadLibrary(const std::string & library_path, ClassLoader * loader)
return;
} catch (const Poco::RuntimeException & e) {
delete (library);
throw(class_loader::LibraryUnloadException(
"Could not unload library (Poco exception = " + std::string(e.message()) + ")"));
throw class_loader::LibraryUnloadException(
"Could not unload library (Poco exception = " + std::string(e.message()) + ")");
}
}
throw(class_loader::LibraryUnloadException(
"Attempt to unload library that class_loader is unaware of."));
throw class_loader::LibraryUnloadException(
"Attempt to unload library that class_loader is unaware of.");
}
}

Expand Down

0 comments on commit ab207e1

Please sign in to comment.