Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DOML Model Checker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PIACERE
public
The Platform
DOML Model Checker
Commits
b1f2f1d5
Unverified
Commit
b1f2f1d5
authored
1 year ago
by
Andrea Franchini
Browse files
Options
Downloads
Patches
Plain Diff
fix 400 error return object
parent
821d597a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mc_openapi/fastapi.py
+25
-10
25 additions, 10 deletions
mc_openapi/fastapi.py
with
25 additions
and
10 deletions
mc_openapi/fastapi.py
+
25
−
10
View file @
b1f2f1d5
import
logging
import
os
import
traceback
from
fastapi
import
FastAPI
,
HTTPException
,
Request
from
fastapi.responses
import
HTMLResponse
from
importlib.resources
import
files
from
fastapi
import
FastAPI
,
Request
from
fastapi.responses
import
HTMLResponse
,
JSONResponse
from
fastapi.staticfiles
import
StaticFiles
from
fastapi.templating
import
Jinja2Templates
from
importlib.resources
import
files
from
fastapi.encoders
import
jsonable_encoder
import
mc_openapi.assets
as
ASSETS
from
mc_openapi.doml_mc
import
(
init_model
,
verify_csp_compatibility
,
verify_model
)
from
mc_openapi.doml_mc.exceptions
import
*
from
mc_openapi.doml_mc.intermediate_model.metamodel
import
DOMLVersion
from
mc_openapi.doml_mc
import
init_model
,
verify_csp_compatibility
,
verify_model
from
mc_openapi.doml_mc.mc
import
ModelChecker
assets
=
files
(
ASSETS
)
...
...
@@ -46,12 +50,23 @@ def handleDOMLX(doml_xmi: bytes, callback) -> dict:
MissingInfrastructureLayerException
,
NoActiveConcreteLayerException
)
as
e
:
raise
HTTPException
(
status_code
=
400
,
detail
=
e
.
errors
)
except
RuntimeError
as
e
:
raise
HTTPException
(
status_code
=
500
,
detail
=
"
An error has occurred.
\n
"
+
traceback
.
format_exc
())
except
Exception
as
e
:
raise
HTTPException
(
status_code
=
400
,
detail
=
"
An error has occurred.
\n
"
+
traceback
.
format_exc
())
return
JSONResponse
(
status_code
=
400
,
content
=
jsonable_encoder
({
"
message
"
:
e
.
errors
,
"
debug_message
"
:
traceback
.
format_exc
()
})
)
except
(
RuntimeError
,
Exception
)
as
e
:
logging
.
error
(
traceback
.
format_exc
())
return
JSONResponse
(
status_code
=
400
,
content
=
jsonable_encoder
({
"
message
"
:
"
An error has occurred. It could be an error within your DOML file. If it persist, try specifying DOML version manually.
"
,
"
debug_message
"
:
traceback
.
format_exc
()
})
)
@app.post
(
"
/modelcheck
"
)
async
def
mc
(
request
:
Request
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment