Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
a2272553
Commit
a2272553
authored
May 24, 2018
by
Maxime Perrotin
Browse files
Add error handling when code generation fails
parent
b5d38580
Changes
2
Hide whitespace changes
Inline
Side-by-side
opengeode/AdaGenerator.py
View file @
a2272553
...
...
@@ -149,7 +149,7 @@ def external_ri_list(process):
@
singledispatch
def
generate
(
*
args
,
**
kwargs
):
''' Generate the code for an item of the AST '''
raise
TypeError
(
'
[AdaGenerator] Unsupported AST construct
'
)
raise
TypeError
(
'
Incorrect, unsupported or missing data in model AST
'
)
return
[],
[]
...
...
opengeode/opengeode.py
View file @
a2272553
...
...
@@ -2236,7 +2236,10 @@ class SDL_View(QtGui.QGraphicsView, object):
ast
,
warnings
,
errors
=
ogParser
.
parse_pr
(
files
=
self
.
readonly_pr
,
string
=
pr_data
)
scene
.
semantic_errors
=
True
if
errors
else
False
process
,
=
ast
.
processes
try
:
process
,
=
ast
.
processes
except
ValueError
:
process
=
None
log_errors
(
self
.
messages_window
,
errors
,
warnings
)
if
len
(
errors
)
>
0
:
self
.
messages_window
.
addItem
(
...
...
@@ -2249,7 +2252,7 @@ class SDL_View(QtGui.QGraphicsView, object):
except
(
TypeError
,
ValueError
,
NameError
)
as
err
:
self
.
messages_window
.
addItem
(
'Code generation failed:'
+
str
(
err
))
LOG
.
error
(
str
(
traceback
.
format_exc
()))
LOG
.
debug
(
str
(
traceback
.
format_exc
()))
def
generate_qgen_ada
(
self
):
''' Generate Ada code using QGen '''
...
...
@@ -2262,7 +2265,10 @@ class SDL_View(QtGui.QGraphicsView, object):
ast
,
warnings
,
errors
=
ogParser
.
parse_pr
(
files
=
self
.
readonly_pr
,
string
=
pr_data
)
scene
.
semantic_errors
=
True
if
errors
else
False
process
,
=
ast
.
processes
try
:
process
,
=
ast
.
processes
except
ValueError
:
process
=
None
log_errors
(
self
.
messages_window
,
errors
,
warnings
)
if
len
(
errors
)
>
0
:
self
.
messages_window
.
addItem
(
...
...
@@ -2272,7 +2278,10 @@ class SDL_View(QtGui.QGraphicsView, object):
options
=
parse_args
()
options
.
toAda
=
True
options
.
QGen
=
True
errors
=
QGenSDL
.
call_qgensdl
(
options
)
try
:
errors
=
QGenSDL
.
call_qgensdl
(
options
)
except
AttributeError
:
errors
=
True
if
errors
:
self
.
messages_window
.
addItem
(
'Code generation with QGen failed!'
)
...
...
@@ -2290,7 +2299,10 @@ class SDL_View(QtGui.QGraphicsView, object):
ast
,
warnings
,
errors
=
ogParser
.
parse_pr
(
files
=
self
.
readonly_pr
,
string
=
pr_data
)
scene
.
semantic_errors
=
True
if
errors
else
False
process
,
=
ast
.
processes
try
:
process
,
=
ast
.
processes
except
ValueError
:
process
=
None
log_errors
(
self
.
messages_window
,
errors
,
warnings
)
if
len
(
errors
)
>
0
:
self
.
messages_window
.
addItem
(
...
...
@@ -2300,7 +2312,10 @@ class SDL_View(QtGui.QGraphicsView, object):
options
=
parse_args
()
options
.
toC
=
True
options
.
QGen
=
True
errors
=
QGenSDL
.
call_qgensdl
(
options
)
try
:
errors
=
QGenSDL
.
call_qgensdl
(
options
)
except
AttributeError
:
errors
=
True
if
errors
:
self
.
messages_window
.
addItem
(
'Code generation with QGen failed!'
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment