PyXMake Developer Guide 1.0
PyXMake
Loading...
Searching...
No Matches
ErrorHandling.py
1# -*- coding: utf-8 -*-
2# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3# % ErrorHandling Module - Classes and Functions %
4# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5"""
6Collection of custom errors and exceptions.
7
8@note: PyXMake module
9Created 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
31try:
32 from builtins import Exception
33except ImportError:
34 pass
35from ..Tools import Utility
36
37## @class PyXMake.Tools.ErrorHandling.Error
38# Parent class inherited from built-in exception.
39class Error(Exception, Utility.AbstractBase): # pragma: no cover
40 """
41 Base class for all exceptions in this module.
42 """
43 pass
44
45## @class PyXMake.Tools.ErrorHandling.InputError
46# Base class for all input errors. Inherited from Error.
47class InputError(Error): # pragma: no cover
48 """
49 Exception raised for errors in the input.
50
51 Attributes:
52 Expression -- Input expression in which the error occurred
53 """
54 def __init__(self, Expression):
55 """
56 Low-level initialization of input error class.
57 """
58 ## Input expression in which the error occurred. This is the internal error code.
59 self.Expression = Expression
60
61 # Errors associated with the make module.
62 if self.Expression == 0:
63 raise InputError('The temporary input file does not end with *cpd.')
64 if self.Expression == 1:
65 raise InputError('Material dictionary is not given. Please define a material.')
66 if self.Expression == 2:
67 raise InputError('Skin list is empty. Please define the skin geometry of the panel.')
68 if self.Expression == 3:
69 raise NameError('Unknown mesh classification flag. Valid flags are: Structured, Unstructured or Hybrid.')
70 if self.Expression == 4:
71 raise InputError('MeshImplementation list is empty. Please define the mesh discretization.')
72 if self.Expression == 5:
73 raise InputError('No impact points are given.')
74 if self.Expression == 6:
75 raise InputError('An unknown boundary condition is defined. Valid flags are: ENCASTRE or PINNED.')
76 if self.Expression == 7:
77 raise NameError('Unknown API. Only Abaqus, Salome and Gmsh can be used for mesh generation.')
78
79 # Errors associated with the build module.
80 if self.Expression == 10:
81 raise NameError('Unknown Solver. Only Abaqus, Calculix and Marc are supported. Please use a different solver.')
82
83 # Errors associated with the VTL module.
84 if self.Expression == 20:
85 raise NameError('Import Error. Function is executed as a plug-in, but cannot load a required dependency')
86 if self.Expression == 21:
87 raise NameError('Import Error. Mismatch between source code uploaded and requested. Please check content of your input.')
88
89## @class PyXMake.Tools.ErrorHandling.TransitionError
90# Base class for all transition errors. Inherited from Error.
91class TransitionError(Error): # pragma: no cover
92 """
93 Raised when an operation attempts a state transition that's not allowed.
94
95 Attributes:
96 Previous -- State at beginning of transition
97 Following -- Attempted new state
98 Message -- Explanation of why the specific transition is not allowed
99 """
100 def __init__(self, Previous, Following, Message):
101 """
102 Low-level initialization of transition error class.
103 """
104 ## State at beginning of transition.
105 self.Previous = Previous
106 ## Attempted new state.
107 self.Following = Following
108 ## Explanation of why the specific transition is not allowed.
109 self.Message = Message
110
111if __name__ == '__main__':
112 pass
Parent class inherited from built-in exception.
Base class for all input errors.
int Expression
Input expression in which the error occurred.
Base class for all transition errors.
Message
Explanation of why the specific transition is not allowed.
__init__(self, Previous, Following, Message)
Previous
State at beginning of transition.
Abstract meta class for all data class objects.