PyXMake Developer Guide  1.0
PyXMake
ErrorHandling.py
1 # -*- coding: utf-8 -*-
2 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 # % ErrorHandling Module - Classes and Functions %
4 # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 """
6 Collection of custom errors and exceptions.
7 
8 @note: PyXMake module
9 Created on 20.03.2018
10 
11 @version: 1.0
12 ----------------------------------------------------------------------------------------------
13 @requires:
14  -
15 
16 @change:
17  -
18 
19 @author: garb_ma [DLR-FA,STM Braunschweig]
20 ----------------------------------------------------------------------------------------------
21 """
22 
23 ## @package PyXMake.Tools.ErrorHandling
24 # Error handling module.
25 ## @author
26 # Marc Garbade
27 ## @date
28 # 20.03.2018
29 ## @par Notes/Changes
30 # - Added documentation // mg 29.03.2018
31 try:
32  from builtins import Exception
33 except ImportError:
34  pass
35 from ..Tools import Utility
36 
37 ## @class PyXMake.Tools.ErrorHandling.Error
38 # Parent class inherited from built-in exception.
39 class Error(Exception):
40  """
41  Base class for all exceptions in this module.
42  """
43  def __getstate__(self):
44  """
45  Prepare the object for pickling (2to3 compatible)
46  """
47  _dictobj = Utility.PrepareObjectforPickling(self)
48  return _dictobj
49  def __setstate__(self, _dict):
50  """
51  Recover a dictionary from pickling (2to3 compatible)
52  """
53  _dictobj = Utility.RecoverDictionaryfromPickling(_dict)
54  self.__dict__.update(_dictobj)
55  pass
56  pass
57 
58 ## @class PyXMake.Tools.ErrorHandling.InputError
59 # Base class for all input errors. Inherited from Error.
61  """
62  Exception raised for errors in the input.
63 
64  Attributes:
65  Expression -- Input expression in which the error occurred
66  """
67  def __init__(self, Expression):
68  """
69  Low-level initialization of input error class.
70  """
71  ## Input expression in which the error occurred. This is the internal error code.
72  self.Expression = Expression
73 
74  # Errors associated with the make module.
75  if self.Expression == 0:
76  raise InputError('The temporary input file does not end with *cpd.')
77  if self.Expression == 1:
78  raise InputError('Material dictionary is not given. Please define a material.')
79  if self.Expression == 2:
80  raise InputError('Skin list is empty. Please define the skin geometry of the panel.')
81  if self.Expression == 3:
82  raise NameError('Unknown mesh classification flag. Valid flags are: Structured, Unstructured or Hybrid.')
83  if self.Expression == 4:
84  raise InputError('MeshImplementation list is empty. Please define the mesh discretization.')
85  if self.Expression == 5:
86  raise InputError('No impact points are given.')
87  if self.Expression == 6:
88  raise InputError('An unknown boundary condition is defined. Valid flags are: ENCASTRE or PINNED.')
89  if self.Expression == 7:
90  raise NameError('Unknown API. Only Abaqus, Salome and Gmsh can be used for mesh generation.')
91 
92  # Errors associated with the build module.
93  if self.Expression == 10:
94  raise NameError('Unknown Solver. Only Abaqus, Calculix and Marc are supported. Please use a different solver.')
95 
96  # Errors associated with the VTL module.
97  if self.Expression == 20:
98  raise NameError('Import Error. Function is executed as a plug-in, but cannot load a required dependency')
99  if self.Expression == 21:
100  raise NameError('Import Error. Mismatch between source code uploaded and requested. Please check content of your input.')
101 
102 ## @class PyXMake.Tools.ErrorHandling.TransitionError
103 # Base class for all transition errors. Inherited from Error.
105  """
106  Raised when an operation attempts a state transition that's not allowed.
107 
108  Attributes:
109  Previous -- State at beginning of transition
110  Following -- Attempted new state
111  Message -- Explanation of why the specific transition is not allowed
112  """
113  def __init__(self, Previous, Following, Message):
114  """
115  Low-level initialization of transition error class.
116  """
117  ## State at beginning of transition.
118  self.Previous = Previous
119  ## Attempted new state.
120  self.Following = Following
121  ## Explanation of why the specific transition is not allowed.
122  self.Message = Message
123 
124 if __name__ == '__main__':
125  pass
Parent class inherited from built-in exception.
Message
Explanation of why the specific transition is not allowed.
Previous
State at beginning of transition.
Base class for all input errors.
Expression
Input expression in which the error occurred.
Base class for all transition errors.
def __init__(self, Previous, Following, Message)