Skip to content
Snippets Groups Projects
Commit 1f851918 authored by Cain, Payton David's avatar Cain, Payton David
Browse files

Raise value error with HTTPException

parent 3a9d06c9
No related branches found
No related tags found
2 merge requests!146Release CMO metadata to production,!91Residual Calculation for Web Service
......@@ -33,11 +33,7 @@ def get_dbdt(
@router.post("/algorithms/residual", response_model=Reading)
def calculate_residual(reading: Reading, adjust_reference: bool = True):
missing_types = reading.get_missing_measurement_types()
if len(missing_types) != 0:
missing_types = ", ".join(t.value for t in missing_types)
raise HTTPException(
status_code=400,
detail=f"Missing {missing_types} measurements in input reading",
)
return calculate(reading=reading, adjust_reference=adjust_reference)
try:
return calculate(reading=reading, adjust_reference=adjust_reference)
except ValueError as e:
raise HTTPException(status_code=400, detail=str(e))
......@@ -8,10 +8,14 @@ from pydantic import BaseModel
from .. import TimeseriesUtility
from ..TimeseriesFactory import TimeseriesFactory
from .Absolute import Absolute
from .Calculation import DECLINATION_TYPES, INCLINATION_TYPES, MARK_TYPES
from .Measurement import Measurement, average_measurement
from .Diagnostics import Diagnostics
from .MeasurementType import MeasurementType
from .MeasurementType import (
MeasurementType,
DECLINATION_TYPES,
INCLINATION_TYPES,
MARK_TYPES,
)
class Reading(BaseModel):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment