Browse Source

Refactor error messages

This patch refactors error messages and
shows the detailed error message

Change-Id: I4d7fc03c9368bf20cd374097ff210e1ecb952d23
tags/9.0.0.0b1
pengyuesheng 1 week ago
parent
commit
809416b7b5

+ 4
- 4
mistraldashboard/actions/forms.py View File

@@ -130,8 +130,8 @@ class CreateForm(forms.SelfHandlingForm):
130 130
             messages.success(request, msg)
131 131
 
132 132
             return True
133
-        except Exception:
134
-            msg = _('Failed to create action.')
133
+        except Exception as e:
134
+            msg = _('Failed to create action: %s') % e
135 135
             redirect = reverse('horizon:mistral:actions:index')
136 136
             exceptions.handle(request, msg, redirect=redirect)
137 137
 
@@ -188,7 +188,7 @@ class UpdateForm(forms.SelfHandlingForm):
188 188
             messages.success(request, msg)
189 189
 
190 190
             return True
191
-        except Exception:
192
-            msg = _('Failed to update action.')
191
+        except Exception as e:
192
+            msg = _('Failed to update action: %s') % e
193 193
             redirect = reverse('horizon:mistral:actions:index')
194 194
             exceptions.handle(request, msg, redirect=redirect)

+ 2
- 2
mistraldashboard/executions/forms.py View File

@@ -39,7 +39,7 @@ class UpdateDescriptionForm(forms.SelfHandlingForm):
39 39
 
40 40
             return True
41 41
 
42
-        except Exception:
43
-            msg = _('Failed to update execution description.')
42
+        except Exception as e:
43
+            msg = _('Failed to update execution description: %s') % e
44 44
             redirect = reverse('horizon:mistral:executions:index')
45 45
             exceptions.handle(request, msg, redirect=redirect)

+ 5
- 4
mistraldashboard/executions/views.py View File

@@ -113,10 +113,10 @@ class IndexView(tables.DataTableView):
113 113
                     reverse=True
114 114
                 )
115 115
 
116
-        except Exception:
116
+        except Exception as e:
117 117
             self._prev = False
118 118
             self._more = False
119
-            msg = _('Unable to retrieve executions list.')
119
+            msg = _('Unable to retrieve executions list: %s') % e
120 120
             exceptions.handle(self.request, msg)
121 121
 
122 122
         return executions
@@ -168,11 +168,12 @@ class TasksView(tables.DataTableView):
168 168
                     reverse=True
169 169
                 )
170 170
 
171
-        except Exception:
171
+        except Exception as e:
172 172
             self._prev = False
173 173
             self._more = False
174 174
             msg = (
175
-                _('Unable to retrieve executions list of the requested task.')
175
+                _('Unable to retrieve executions list of '
176
+                  'the requested task: %s') % e
176 177
             )
177 178
             exceptions.handle(self.request, msg)
178 179
 

+ 4
- 4
mistraldashboard/workbooks/forms.py View File

@@ -108,8 +108,8 @@ class CreateForm(forms.SelfHandlingForm):
108 108
             messages.success(request, msg)
109 109
 
110 110
             return True
111
-        except Exception:
112
-            msg = _('Failed to create workbook.')
111
+        except Exception as e:
112
+            msg = _('Failed to create workbook: %s') % e
113 113
             redirect = reverse('horizon:mistral:workbooks:index')
114 114
             exceptions.handle(request, msg, redirect=redirect)
115 115
 
@@ -123,7 +123,7 @@ class UpdateForm(CreateForm):
123 123
             messages.success(request, msg)
124 124
 
125 125
             return True
126
-        except Exception:
127
-            msg = _('Failed to update workbook.')
126
+        except Exception as e:
127
+            msg = _('Failed to update workbook: %s') % e
128 128
             redirect = reverse('horizon:mistral:workbooks:index')
129 129
             exceptions.handle(request, msg, redirect=redirect)

+ 4
- 4
mistraldashboard/workflows/forms.py View File

@@ -161,8 +161,8 @@ class CreateForm(forms.SelfHandlingForm):
161 161
             messages.success(request, msg)
162 162
 
163 163
             return True
164
-        except Exception:
165
-            msg = _('Failed to create workflow.')
164
+        except Exception as e:
165
+            msg = _('Failed to create workflow: %s') % e
166 166
             redirect = reverse('horizon:mistral:workflows:index')
167 167
             exceptions.handle(request, msg, redirect=redirect)
168 168
 
@@ -176,7 +176,7 @@ class UpdateForm(CreateForm):
176 176
             messages.success(request, msg)
177 177
 
178 178
             return True
179
-        except Exception:
180
-            msg = _('Failed to update workflow.')
179
+        except Exception as e:
180
+            msg = _('Failed to update workflow: %s') % e
181 181
             redirect = reverse('horizon:mistral:workflows:index')
182 182
             exceptions.handle(request, msg, redirect=redirect)

Loading…
Cancel
Save