Add possibility to retrieve textual description of errors from service
authorDavin McCall <davmac@davmac.org>
Mon, 23 Nov 2015 09:25:13 +0000 (09:25 +0000)
committerDavin McCall <davmac@davmac.org>
Mon, 23 Nov 2015 09:25:13 +0000 (09:25 +0000)
load exceptions.

service.h

index a5b3d135287ae9fac926ade3c4c7ffa80db80b7d..7f4ae224e4d616f924c265ff8e28254445148434 100644 (file)
--- a/service.h
+++ b/service.h
@@ -60,7 +60,9 @@ class ServiceLoadExc
 {
     public:
     std::string serviceName;
+    const char *excDescription;
     
+    protected:
     ServiceLoadExc(std::string serviceName) noexcept
         : serviceName(serviceName)
     {
@@ -73,6 +75,7 @@ class ServiceNotFound : public ServiceLoadExc
     ServiceNotFound(std::string serviceName) noexcept
         : ServiceLoadExc(serviceName)
     {
+        excDescription = "Not found.";
     }
 };
 
@@ -82,6 +85,7 @@ class ServiceCyclicDependency : public ServiceLoadExc
     ServiceCyclicDependency(std::string serviceName) noexcept
         : ServiceLoadExc(serviceName)
     {
+        excDescription = "Cyclic dependency.";
     }
 };
 
@@ -93,6 +97,7 @@ class ServiceDescriptionExc : public ServiceLoadExc
     ServiceDescriptionExc(std::string serviceName, std::string extraInfo) noexcept
         : ServiceLoadExc(serviceName), extraInfo(extraInfo)
     {
+        excDescription = extraInfo.c_str();
     }    
 };