diff --git a/library/map.m b/library/map.m index f2de80295..1e386e9d0 100644 --- a/library/map.m +++ b/library/map.m @@ -225,12 +225,12 @@ map__lookup(Map, K, V) :- ( 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 @@ map__lookup_error(K, V) :- 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 @@ map__det_insert(Map0, K, V, Map) :- ( 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 @@ map__det_update(Map0, K, V, Map) :- ( 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 @@ map__det_remove(Map0, Key, Value, Map) :- 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) :- diff --git a/library/map.nu.nl b/library/map.nu.nl index 8f7df5417..d89de84e4 100644 --- a/library/map.nu.nl +++ b/library/map.nu.nl @@ -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(Map0, K, V, Map) :- % 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"). %-----------------------------------------------------------------------------% %-----------------------------------------------------------------------------%