trivial diff: map error messages

Simon Taylor stayl at cs.mu.OZ.AU
Wed Aug 26 15:46:46 AEST 1998


Estimated hours taken: 0.1

library/map.m:
	Use map__lookup_error for the other map predicates
	which abort on missing or duplicate keys.

library/map.nu.nl:
	Fix the message for map__det_insert_error.


Index: map.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/map.m,v
retrieving revision 1.64
diff -u -t -u -r1.64 map.m
--- map.m	1998/07/13 19:53:39	1.64
+++ map.m	1998/08/24 04:07:05
@@ -225,12 +225,12 @@
         ( tree234__search(Map, K, V1) ->
                 V = V1
         ;
-                map__lookup_error(K, V)
+                map__lookup_error("map__lookup: key_not_found", K, V)
         ).
 
-:- pred map__lookup_error(K, V).
-:- mode map__lookup_error(in, unused) is erroneous.
-map__lookup_error(K, V) :-
+:- pred map__lookup_error(string, K, V).
+:- mode map__lookup_error(in, in, unused) is erroneous.
+map__lookup_error(Msg, K, V) :-
         KeyType = type_name(type_of(K)),
         ValueType = type_name(type_of(V)),
         functor(K, Functor, Arity),
@@ -242,8 +242,8 @@
                         FunctorStr)
         ),
         string__append_list(
-                ["map__lookup: key not found\n",
-                "\tKey Type: ",
+                [Msg,
+                "\n\tKey Type: ",
                 KeyType,
                 "\n\tKey Functor: ",
                 FunctorStr,
@@ -260,7 +260,7 @@
         ( tree234__insert(Map0, K, V, Map1) ->
                 Map = Map1
         ;
-                error("map__det_insert: key already present")
+                map__lookup_error("map__det_insert: key already present", K, V)
         ).
 
 map__det_insert_from_corresponding_lists(Map0, Ks, Vs, Map) :-
@@ -283,7 +283,7 @@
         ( tree234__update(Map0, K, V, Map1) ->
                 Map = Map1
         ;
-                error("map__det_update: key not found")
+                map__lookup_error("map__det_update: key not found", K, V)
         ).
 
 map__set(Map0, K, V, Map) :-
@@ -320,7 +320,7 @@
                 Value = Value1,
                 Map = Map1
         ;
-                error("map__det_remove: key not found")
+                map__lookup_error("map__det_remove: key not found", Key, Value)
         ).
 
 map__count(Map, Count) :-
Index: map.nu.nl
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/map.nu.nl,v
retrieving revision 1.5
diff -u -t -u -r1.5 map.nu.nl
--- map.nu.nl	1997/09/06 17:41:34	1.5
+++ map.nu.nl	1998/08/26 05:44:36
@@ -1,5 +1,5 @@
 %---------------------------------------------------------------------------%
-% Copyright (C) 1997 The University of Melbourne.
+% Copyright (C) 1997-1998 The University of Melbourne.
 % This file may only be copied under the terms of the GNU Library General
 % Public License - see the file COPYING.LIB in the Mercury distribution.
 %---------------------------------------------------------------------------%
@@ -37,7 +37,7 @@
 % map__det_insert_error is a separate predicate because it is handy
 % to be able to set a spy point on it...
 map__det_insert_error(_Map, _K, _V) :-
-        error("map__det_insert: key not found").
+        error("map__det_insert: key already present").
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%



More information about the developers mailing list