DAQ: added error handling for mount exceptions in server.py.
This commit is contained in:
1 parent
dab6124928
commit
4196a1e468
1 file changed
+13
-4
@@ -27,8 +27,6 @@ from aaredaqlib.beamline import mx_beamline
|
||||
from aaredaq.config import BeamlineConfig
|
||||
from aaredaq.daq import AareDAQ, LoopCenteringFailed, TransformationInvalidException, MountingFailed
|
||||
|
||||
from aaredaq.camera_stat_thread import start_image_stats_receiver, stop_image_stats_receiver
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
# OAuth2 setup
|
||||
@@ -253,7 +251,18 @@ async def mount(dbid: int, token: str = Depends(oauth2_scheme), reference: bool
|
||||
if index == -1:
|
||||
raise RuntimeError("Sample not found")
|
||||
if token_data.staff or st.s[index].user in token_data.pgroups:
|
||||
daq.sample = st.s[index]
|
||||
try:
|
||||
daq.sample = st.s[index]
|
||||
except MountingFailed(Exception) as e:
|
||||
raise HTTPException(
|
||||
status_code=api_status.HTTP_404_NOT_FOUND,
|
||||
detail=f"{e}",
|
||||
)
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
status_code=api_status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
detail=f"{e}"
|
||||
)
|
||||
return "OK"
|
||||
else:
|
||||
raise HTTPException(
|
||||
@@ -399,7 +408,7 @@ async def auto(s: SampleShortInfo, token: str = Depends(oauth2_scheme)):
|
||||
except MountingFailed(Exception) as e:
|
||||
raise HTTPException(
|
||||
status_code=api_status.HTTP_404_NOT_FOUND,
|
||||
detail=f"Mounting failed: {e}",
|
||||
detail=f"{e}",
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Exception in auto: {e}")
|
||||
|
||||
Reference in new issue
Block a user