issue #1700 replace raise Exception()

This commit is contained in:
Sebastian Hoogen 2014-08-24 14:33:10 +02:00
parent e5a54d0791
commit a81a307346
19 changed files with 38 additions and 37 deletions

View File

@ -1510,7 +1510,7 @@ def fillet(lEdges,r,chamfer=False):
elif issubclass(type(edge.Curve),Part.Circle) :
existingCurveType['Arc'] += [edge]
else :
raise Exception("Edge's curve must be either Line or Arc")
raise ValueError("Edge's curve must be either Line or Arc")
return existingCurveType
rndEdges = lEdges[0:2]

View File

@ -194,7 +194,7 @@ void ShapeBuilderWidget::createEdgeFromVertex()
QString cmd;
cmd = QString::fromAscii(
"_=Part.makeLine(%1, %2)\n"
"if _.isNull(): raise Exception('Failed to create edge')\n"
"if _.isNull(): raise RuntimeError('Failed to create edge')\n"
"App.ActiveDocument.addObject('Part::Feature','Edge').Shape=_\n"
"del _\n"
).arg(elements[0]).arg(elements[1]);
@ -237,7 +237,7 @@ void ShapeBuilderWidget::createFaceFromVertex()
if (d->ui.checkPlanar->isChecked()) {
cmd = QString::fromAscii(
"_=Part.Face(Part.makePolygon(%1, True))\n"
"if _.isNull(): raise Exception('Failed to create face')\n"
"if _.isNull(): raise RuntimeError('Failed to create face')\n"
"App.ActiveDocument.addObject('Part::Feature','Face').Shape=_\n"
"del _\n"
).arg(list);
@ -245,7 +245,7 @@ void ShapeBuilderWidget::createFaceFromVertex()
else {
cmd = QString::fromAscii(
"_=Part.makeFilledFace([Part.makePolygon(%1, True)])\n"
"if _.isNull(): raise Exception('Failed to create face')\n"
"if _.isNull(): raise RuntimeError('Failed to create face')\n"
"App.ActiveDocument.addObject('Part::Feature','Face').Shape=_\n"
"del _\n"
).arg(list);
@ -289,7 +289,7 @@ void ShapeBuilderWidget::createFaceFromEdge()
if (d->ui.checkPlanar->isChecked()) {
cmd = QString::fromAscii(
"_=Part.Face(Part.Wire(Part.__sortEdges__(%1)))\n"
"if _.isNull(): raise Exception('Failed to create face')\n"
"if _.isNull(): raise RuntimeError('Failed to create face')\n"
"App.ActiveDocument.addObject('Part::Feature','Face').Shape=_\n"
"del _\n"
).arg(list);
@ -297,7 +297,7 @@ void ShapeBuilderWidget::createFaceFromEdge()
else {
cmd = QString::fromAscii(
"_=Part.makeFilledFace(Part.__sortEdges__(%1))\n"
"if _.isNull(): raise Exception('Failed to create face')\n"
"if _.isNull(): raise RuntimeError('Failed to create face')\n"
"App.ActiveDocument.addObject('Part::Feature','Face').Shape=_\n"
"del _\n"
).arg(list);
@ -351,7 +351,7 @@ void ShapeBuilderWidget::createShellFromFace()
QString cmd;
cmd = QString::fromAscii(
"_=Part.Shell(%1)\n"
"if _.isNull(): raise Exception('Failed to create shell')\n"
"if _.isNull(): raise RuntimeError('Failed to create shell')\n"
"App.ActiveDocument.addObject('Part::Feature','Shell').Shape=_.removeSplitter()\n"
"del _\n"
).arg(list);
@ -389,9 +389,9 @@ void ShapeBuilderWidget::createSolidFromShell()
QString cmd;
cmd = QString::fromAscii(
"shell=%1\n"
"if shell.ShapeType != 'Shell': raise Exception('Part object is not a shell')\n"
"if shell.ShapeType != 'Shell': raise RuntimeError('Part object is not a shell')\n"
"_=Part.Solid(shell)\n"
"if _.isNull(): raise Exception('Failed to create solid')\n"
"if _.isNull(): raise RuntimeError('Failed to create solid')\n"
"App.ActiveDocument.addObject('Part::Feature','Solid').Shape=_.removeSplitter()\n"
"del _\n"
).arg(line);

View File

@ -32,7 +32,7 @@ class Epitrochoid:
z=0
if r2 == 0:
raise Exception("Exterior radius must not be zero")
raise ValueError("Exterior radius must not be zero")
for i in range(steps):
if i==0:
@ -66,4 +66,4 @@ def makeEpitrochoid():
doc.recompute()
if __name__ == "__main__": #feature will be generated after macro execution
makeEpitrochoid()
makeEpitrochoid()

View File

@ -75,7 +75,7 @@ def makeFilletArc(M1,P,Q,N,r2,ccw):
cc = 2.0 * r2 * (b.dot(v)-r1)
dd = uv * uv - uu * cc
if dd < 0:
raise Exception("Unable to caluclate intersection points")
raise RuntimeError("Unable to caluclate intersection points")
t1 = (-uv + math.sqrt(dd)) / uu
t2 = (-uv - math.sqrt(dd)) / uu

View File

@ -47,7 +47,7 @@ def makeRadialCopy():
sel = sel[0]
shape = sel.Shape
name = sel.Label
except:
except IndexError, AttributeError:
QtGui.QMessageBox.critical(None,"Wrong selection","Please select a shape object")
#raise Exception("Nothing selected")
else:

View File

@ -155,7 +155,7 @@ class TaskPanel:
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
def widget(self, class_id, name):
"""Return the selected widget.

View File

@ -114,7 +114,7 @@ class TaskPanel:
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
def widget(self, class_id, name):
"""Return the selected widget.

View File

@ -103,7 +103,7 @@ class TaskPanel:
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
def widget(self, class_id, name):
"""Return the selected widget.

View File

@ -110,7 +110,7 @@ class TaskPanel:
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
def widget(self, class_id, name):
"""Return the selected widget.

View File

@ -131,7 +131,7 @@ class TaskPanel:
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
def widget(self, class_id, name):
"""Return the selected widget.

View File

@ -119,7 +119,7 @@ class TaskPanel:
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
def widget(self, class_id, name):
"""Return the selected widget.

View File

@ -112,7 +112,7 @@ class TaskPanel:
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
def widget(self, class_id, name):
"""Return the selected widget.

View File

@ -170,7 +170,7 @@ class TaskPanel:
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
def widget(self, class_id, name):
"""Return the selected widget.

View File

@ -88,7 +88,7 @@ class TaskPanel:
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
def widget(self, class_id, name):
"""Return the selected widget.

View File

@ -160,7 +160,7 @@ class TaskPanel:
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
def widget(self, class_id, name):
"""Return the selected widget.

View File

@ -39,14 +39,14 @@ class MathParser:
}
for var in vars.keys():
if self.vars.get(var) != None:
raise Exception("Cannot redefine the value of " + var)
raise RuntimeError("Cannot redefine the value of " + var)
self.vars[var] = vars[var]
def getValue(self):
value = self.parseExpression()
self.skipWhitespace()
if self.hasNext():
raise Exception(
raise SyntaxError(
"Unexpected character found: '" +
self.peek() +
"' at index " +
@ -97,7 +97,7 @@ class MathParser:
self.index += 1
denominator = self.parseParenthesis()
if denominator == 0:
raise Exception(
raise ZeroDivisionError(
"Division by 0 kills baby whales (occured at index " +
str(div_index) +
")")
@ -117,7 +117,7 @@ class MathParser:
value = self.parseExpression()
self.skipWhitespace()
if self.peek() != ')':
raise Exception(
raise SyntaxError(
"No closing parenthesis found at character "
+ str(self.index))
self.index += 1
@ -155,7 +155,7 @@ class MathParser:
value = self.vars.get(var, None)
if value == None:
raise Exception(
raise ValueError(
"Unrecognized variable: '" +
var +
"'")
@ -171,7 +171,7 @@ class MathParser:
char = self.peek()
if char == '.':
if decimal_found:
raise Exception(
raise SyntaxError(
"Found an extra period in a number at character " +
str(self.index) +
". Are you European?")
@ -185,9 +185,9 @@ class MathParser:
if len(strValue) == 0:
if char == '':
raise Exception("Unexpected end found")
raise SyntaxError("Unexpected end found")
else:
raise Exception(
raise SyntaxError(
"I was expecting to find a number at character " +
str(self.index) +
" but instead I found a '" +
@ -439,8 +439,9 @@ class Spreadsheet:
p = MathParser(result)
result = p.getValue()
except Exception as (ex):
msg = ex.message
raise Exception(msg)
raise #
#msg = ex.message
#raise Exception(msg) #would discard the type
return result
def recompute(self,obj):

View File

@ -18,7 +18,7 @@ def makeSnapshotWithGui():
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
mw=getMainWindow()
mw.hide()

View File

@ -13,7 +13,7 @@ class DocumentObject(object):
def execute(self):
"this method is executed on object creation and whenever the document is recomputed"
raise Exception("Not yet implemented")
raise NotImplementedError("Not yet implemented")
def init(self):
#will be called just after object creation, you can use this for example to create properties

View File

@ -84,8 +84,8 @@ class TaskPanel:
for i in toplevel:
if i.metaObject().className() == "Gui::MainWindow":
return i
raise Exception("No main window found")
raise RuntimeError("No main window found")
def addElement(self):
item=QtGui.QInputDialog.getText(self.form, 'Add item', 'Enter:')
if item[1]: