@@ -1990,6 +1990,12 @@ def coord(
19901990            if  name_or_coord  is  not None :
19911991                if  not  isinstance (name_or_coord , str ):
19921992                    _name  =  name_or_coord .name ()
1993+                     emsg  =  (
1994+                         "Expected to find exactly 1 coordinate matching the given " 
1995+                         f"{ _name !r}  
1996+                     )
1997+                     raise  iris .exceptions .CoordinateNotFoundError (emsg )
1998+ 
19931999            bad_name  =  _name  or  standard_name  or  long_name  or  "" 
19942000            emsg  =  (
19952001                f"Expected to find exactly 1 { bad_name !r}  
@@ -2194,9 +2200,15 @@ def cell_measure(self, name_or_cell_measure=None):
21942200                bad_name  =  (
21952201                    name_or_cell_measure  and  name_or_cell_measure .name ()
21962202                ) or  "" 
2203+                 if  name_or_cell_measure  is  not None :
2204+                     emsg  =  (
2205+                         "Expected to find exactly 1 cell measure matching the given " 
2206+                         f"{ bad_name !r}  
2207+                     )
2208+                     raise  iris .exceptions .CellMeasureNotFoundError (emsg )
21972209            msg  =  (
2198-                 "Expected to find exactly 1 %s cell_measure, but found  " 
2199-                 "none."   %   bad_name 
2210+                 f "Expected to find exactly 1 { bad_name !r }  cell measure,  "
2211+                 "but found  none." 
22002212            )
22012213            raise  iris .exceptions .CellMeasureNotFoundError (msg )
22022214
@@ -2281,9 +2293,16 @@ def ancillary_variable(self, name_or_ancillary_variable=None):
22812293                    name_or_ancillary_variable 
22822294                    and  name_or_ancillary_variable .name ()
22832295                ) or  "" 
2296+                 if  name_or_ancillary_variable  is  not None :
2297+                     emsg  =  (
2298+                         "Expected to find exactly 1 ancillary_variable matching the " 
2299+                         f"given { bad_name !r}  
2300+                         "none." 
2301+                     )
2302+                     raise  iris .exceptions .AncillaryVariableNotFoundError (emsg )
22842303            msg  =  (
2285-                 "Expected to find exactly 1 {!s } ancillary_variable, but  " 
2286-                 "found none." . format ( bad_name ) 
2304+                 f "Expected to find exactly 1 { bad_name !r } 
2305+                 "but  found none." 
22872306            )
22882307            raise  iris .exceptions .AncillaryVariableNotFoundError (msg )
22892308
0 commit comments