77 "KernelError" ,
88 "StatusCode" ,
99 "TimeExtrapolationError" ,
10+ "_raise_field_interpolation_error" ,
1011 "_raise_field_out_of_bound_error" ,
1112 "_raise_field_out_of_bound_surface_error" ,
12- "_raise_field_sampling_error" ,
13+ "_raise_general_error" ,
14+ "_raise_grid_searching_error" ,
1315 "_raise_time_extrapolation_error" ,
1416]
1517
@@ -25,37 +27,38 @@ class StatusCode:
2527 StopAllExecution = 41
2628 Error = 50
2729 ErrorInterpolation = 51
30+ ErrorGridSearching = 52
2831 ErrorOutOfBounds = 60
2932 ErrorThroughSurface = 61
3033 ErrorTimeExtrapolation = 70
3134
3235
33- class FieldSamplingError (RuntimeError ):
34- """Utility error class to propagate erroneous field sampling ."""
36+ class FieldInterpolationError (RuntimeError ):
37+ """Utility error class to propagate NaN field interpolation ."""
3538
3639 pass
3740
3841
42+ def _raise_field_interpolation_error (z , y , x ):
43+ raise FieldInterpolationError (f"Field interpolation returned NaN at (depth={ z } , lat={ y } , lon={ x } )" )
44+
45+
3946class FieldOutOfBoundError (RuntimeError ):
4047 """Utility error class to propagate out-of-bound field sampling."""
4148
4249 pass
4350
4451
52+ def _raise_field_out_of_bound_error (z , y , x ):
53+ raise FieldOutOfBoundError (f"Field sampled out-of-bound, at (depth={ z } , lat={ y } , lon={ x } )" )
54+
55+
4556class FieldOutOfBoundSurfaceError (RuntimeError ):
4657 """Utility error class to propagate out-of-bound field sampling at the surface."""
4758
4859 pass
4960
5061
51- def _raise_field_sampling_error (z , y , x ):
52- raise FieldSamplingError (f"Field sampled at (depth={ z } , lat={ y } , lon={ x } )" )
53-
54-
55- def _raise_field_out_of_bound_error (z , y , x ):
56- raise FieldOutOfBoundError (f"Field sampled out-of-bound, at (depth={ z } , lat={ y } , lon={ x } )" )
57-
58-
5962def _raise_field_out_of_bound_surface_error (z : float | None , y : float | None , x : float | None ) -> None :
6063 def format_out (val ):
6164 return "unknown" if val is None else val
@@ -65,6 +68,32 @@ def format_out(val):
6568 )
6669
6770
71+ class FieldSamplingError (RuntimeError ):
72+ """Utility error class to propagate field sampling errors."""
73+
74+ pass
75+
76+
77+ class GridSearchingError (RuntimeError ):
78+ """Utility error class to propagate grid searching errors."""
79+
80+ pass
81+
82+
83+ def _raise_grid_searching_error (z , y , x ):
84+ raise GridSearchingError (f"Grid searching failed at (depth={ z } , lat={ y } , lon={ x } )" )
85+
86+
87+ class GeneralError (RuntimeError ):
88+ """Utility error class to propagate general errors."""
89+
90+ pass
91+
92+
93+ def _raise_general_error (z , y , x ):
94+ raise GeneralError (f"General error occurred at (depth={ z } , lat={ y } , lon={ x } )" )
95+
96+
6897class TimeExtrapolationError (RuntimeError ):
6998 """Utility error class to propagate erroneous time extrapolation sampling."""
7099
@@ -91,9 +120,11 @@ def __init__(self, particle, fieldset=None, msg=None):
91120
92121
93122AllParcelsErrorCodes = {
94- FieldSamplingError : StatusCode .Error ,
123+ FieldInterpolationError : StatusCode .ErrorInterpolation ,
95124 FieldOutOfBoundError : StatusCode .ErrorOutOfBounds ,
96125 FieldOutOfBoundSurfaceError : StatusCode .ErrorThroughSurface ,
126+ GridSearchingError : StatusCode .ErrorGridSearching ,
97127 TimeExtrapolationError : StatusCode .ErrorTimeExtrapolation ,
98128 KernelError : StatusCode .Error ,
129+ GeneralError : StatusCode .Error ,
99130}
0 commit comments