1 /**
2   Copyright: 2017 © LLC CERERIS
3   License: MIT
4   Authors: LLC CERERIS
5 */
6 
7 module dich.exception;
8 
9 import std..string;
10 
11 /// Provides an Exception when trying to get an unregistered instance
12 class ResolveException: Exception
13 {
14   public:
15     /** Creates a ResolveException object
16     
17       Params:
18         message = An exception message
19         key = A type of an exceptioned object
20         name = A name of an exceptioned object
21     */
22     this(string message, string key, string name)
23     {
24       super(format("Exception while resolving type %s named %s: %s", key, name, message));
25     }
26 
27     /** Creates a ResolveException object
28     
29       Params:
30         message = An exception message
31         key = A type of an exceptioned object
32     */
33     this(string message, string key)
34     {
35       super(format("Exception while resolving type %s: %s", key, message));
36     }
37 }
38 
39 /// Provides an Exception when trying to register an instance twice
40 class RegistrationException : Exception
41 {
42   public:
43     /** Creates a RegistrationException object
44     
45       Params:
46         message = An exception message
47         key = A type of an exceptioned object
48     */
49     this(string message, string key)
50     {
51       super(format("Exception while registering type %s: %s", key, message));
52     }
53 }