InjectorExceptions.hpp
Go to the documentation of this file.
1 // @formatter:off
2 //
3 // Balau core C++ library
4 //
5 // Copyright (C) 2008 Bora Software (contact@borasoftware.com)
6 //
7 // Licensed under the Boost Software License - Version 1.0 - August 17th, 2003.
8 // See the LICENSE file for the full license text.
9 //
10 
16 
17 #ifndef COM_BORA_SOFTWARE__BALAU_EXCEPTION__INJECTOR_EXCEPTIONS
18 #define COM_BORA_SOFTWARE__BALAU_EXCEPTION__INJECTOR_EXCEPTIONS
19 
20 #include <Balau/Application/Impl/BindingKey.hpp>
22 
23 namespace Balau::Exception {
24 
29  public: CyclicDependencyException(const char * file, int line, const std::string & st, const std::string & text)
30  : BalauException(file, line, st, "CyclicDependency", text) {}
31 };
32 
37  public: const Impl::BindingKey bindingKey;
38 
39  protected: BindingException(const char * file,
40  int line,
41  const std::string & st,
42  const std::string & name,
43  const Impl::BindingKey & bindingKey_)
44  : BalauException(file, line, st, name, toString(bindingKey_))
45  , bindingKey(bindingKey_.getType(), std::string(bindingKey_.getName())) {}
46 
47  protected: BindingException(const char * file,
48  int line,
49  const std::string & st,
50  const std::string & name,
51  const std::string & str,
52  const Impl::BindingKey & bindingKey_)
53  : BalauException(file, line, st, name, ::toString(str, bindingKey_))
54  , bindingKey(bindingKey_.getType(), std::string(bindingKey_.getName())) {}
55 };
56 
57 inline bool operator == (const BindingException & lhs, const BindingException & rhs) {
58  return lhs.message == rhs.message && lhs.bindingKey == rhs.bindingKey;
59 }
60 
65  public: DuplicateBindingException(const char * file,
66  int line,
67  const std::string & st,
68  const Impl::BindingKey & bindingKey_)
69  : BindingException(file, line, st, "DuplicateBinding", bindingKey_) {}
70 };
71 
76  public: NoBindingException(const char * file, int line, const std::string & st, const Impl::BindingKey & key_)
77  : BindingException(file, line, st, "NoBinding", key_) {}
78 
79  public: explicit NoBindingException(const Impl::BindingKey & bindingKey_)
80  : BindingException("", 0, "", "NoBinding", bindingKey_) {}
81 };
82 
87  public: MissingDependencyException(const char * file,
88  int line,
89  const std::string & st,
90  const Impl::BindingKey & dependentKey_,
91  const Impl::BindingKey & independentKey_)
92  : BindingException(file, line, st, "MissingDependency", ::toString(independentKey_, " is required by "), dependentKey_) {}
93 };
94 
101  public: SharedInjectorException(const char * file,
102  int line,
103  const std::string & st,
104  const Impl::BindingKey & bindingKey_)
105  : BindingException(file, line, st, "SharedInjector", bindingKey_) {}
106 };
107 
112  public: EnvironmentConfigurationException(const char * file,
113  int line,
114  const std::string & st,
115  const std::string & text)
116  : BalauException(file, line, st, "EnvironmentConfiguration", text) {}
117 };
118 
119 } // namespace Balau::Exception
120 
121 #endif // COM_BORA_SOFTWARE__BALAU_EXCEPTION__INJECTOR_EXCEPTIONS
bool operator==(const BalauException &lhs, const BalauException &rhs)
Base class comparison function for Balau exceptions.
Definition: BalauException.hpp:112
Thrown when no binding is found in the injector.
Definition: InjectorExceptions.hpp:86
All exception classes.
Definition: BalauException.hpp:50
Thrown when the supplied binding configuration has a cyclic dependency.
Definition: InjectorExceptions.hpp:28
Thrown when an attempt is made to create a shared pointer binding to the injector.
Definition: InjectorExceptions.hpp:100
Balau::U8String< AllocatorT > toString(const BalauException &e)
Base class toString<AllocatorT> function for Balau exceptions.
Definition: BalauException.hpp:122
const std::string message
The message.
Definition: BalauException.hpp:59
Thrown when there is an issue loading an environment property file.
Definition: InjectorExceptions.hpp:111
Base Balau exception classes.
Base class of all Balau exceptions.
Definition: BalauException.hpp:55
Thrown when an illegal injector binding configuration is attempted.
Definition: InjectorExceptions.hpp:64
Base class of binding exceptions.
Definition: InjectorExceptions.hpp:36
Thrown when no binding is found in the injector.
Definition: InjectorExceptions.hpp:75