fix error messages to obey standard.

This commit is contained in:
Vitor Santos Costa 2010-10-12 22:02:24 +01:00
parent fae29012a9
commit 7f70a797f4
5 changed files with 15 additions and 13 deletions

View File

@ -42,11 +42,11 @@ regexp(RegExp, String, Opts, OUT) :-
check_out(V,_,_,_) :- var(V), !.
check_out([],I,I,_) :- !.
check_out([V|L],I0,IF,G) :- !,
(nonvar(V) -> throw(error(type_error(variable,V),G)) ; true),
(nonvar(V) -> throw(error(uninstantiation_error(V),G)) ; true),
I is I0+1,
check_out(L,I,IF,G).
check_out(OUT,_,_,G) :-
throw(error(type_error(variable,OUT),G)).
throw(error(uninstantiation_error(OUT),G)).
%
% Option processing

View File

@ -443,7 +443,7 @@ prolog:'$wait'(Na/Ar) :-
prolog:'$wait'(_).
frozen(V, G) :- nonvar(V), !,
'$do_error'(type_error(variable,V),frozen(V,G)).
'$do_error'(uninstantiation_error(V),frozen(V,G)).
frozen(V, LG) :-
'$attributes':get_conj_from_attvars([V], LG).

View File

@ -296,6 +296,8 @@ system_message(error(unknown, Where)) -->
[ 'EXISTENCE ERROR- procedure ~w undefined' - [Where] ].
system_message(error(unhandled_exception,Throw)) -->
[ 'UNHANDLED EXCEPTION - message ~w unknown' - [Throw] ].
system_message(error(uninstantiation_error(TE), Where)) -->
[ 'UNINSTANTIATION ERROR - expected unbound term, got ~q' - [TE] ].
system_message(Messg) -->
[ '~q' - Messg ].

View File

@ -99,7 +99,7 @@ thread_create(Goal) :-
thread_create(Goal, Id) :-
G0 = thread_create(Goal, Id),
'$check_callable'(Goal, G0),
( nonvar(Id) -> '$do_error'(type_error(variable,Id),G0) ; true ),
( nonvar(Id) -> '$do_error'(uninstantiation_error(Id),G0) ; true ),
'$thread_options'([], [], Stack, Trail, System, Detached, AtExit, G0),
'$thread_new_tid'(Id),
% '$erase_thread_info'(Id), % this should not be here
@ -116,7 +116,7 @@ thread_create(Goal, Id) :-
thread_create(Goal, Id, Options) :-
G0 = thread_create(Goal, Id, Options),
'$check_callable'(Goal,G0),
( nonvar(Id) -> '$do_error'(type_error(variable,Id),G0) ; true ),
( nonvar(Id) -> '$do_error'(uninstantiation_error(Id),G0) ; true ),
'$thread_options'(Options, Alias, Stack, Trail, System, Detached, AtExit, G0),
'$thread_new_tid'(Id),
% '$erase_thread_info'(Id), % this should not be here
@ -159,7 +159,7 @@ thread_create(Goal, Id, Options) :-
;
\+ atom(Mod)
->
'$do_error'(type_error(atom,Mod),G)
'$do_error'(uninstantiation_error(Mod),G)
;
var(LOpts)
->
@ -207,7 +207,7 @@ thread_create(Goal, Id, Options) :-
% vsc: ?????
thread_defaults(Defaults) :-
nonvar(Defaults), !,
'$do_error'(type_error(variable, Defaults), thread_defaults(Defaults)).
'$do_error'(uninstantion_error(Defaults), thread_defaults(Defaults)).
thread_defaults([stack(Stack), trail(Trail), system(System), detached(Detached), at_exit(AtExit)]) :-
recorded('$thread_defaults',[Stack, Trail, System, Detached, AtExit], _).
@ -314,7 +314,7 @@ thread_self(Id) :-
/* Exit status may be either true, false, exception(Term), or exited(Term) */
thread_join(Id, Status) :-
nonvar(Status), !,
'$do_error'(type_error(variable,Status),thread_join(Id, Status)).
'$do_error'(uninstantiation_error(Status),thread_join(Id, Status)).
thread_join(Id, Status) :-
'$check_thread_or_alias'(Id, thread_join(Id, Status)),
'$thread_id_alias'(Id0, Id),
@ -385,7 +385,7 @@ mutex_create(Mutex) :-
mutex_create(Id, Options) :-
nonvar(Id), !,
'$do_error'(type_error(variable, Id), mutex_create(Id, Options)).
'$do_error'(uninstantiation_error(Id), mutex_create(Id, Options)).
mutex_create(Id, Options) :-
Goal = mutex_create(Id, Options),
'$mutex_options'(Options, Alias, Goal),
@ -562,7 +562,7 @@ mutex_property(Mutex, Prop) :-
message_queue_create(Id, Options) :-
nonvar(Id), !,
'$do_error'(type_error(variable, Id), message_queue_create(Id, Options)).
'$do_error'(uninstantiation_error(Id), message_queue_create(Id, Options)).
message_queue_create(Id, Options) :-
var(Options), !,
'$do_error'(instantiation_error, message_queue_create(Id, Options)).
@ -594,7 +594,7 @@ message_queue_create(Id) :-
message_queue_create(Id, [])
; atom(Id) -> % old behavior
message_queue_create(_, [alias(Id)])
; '$do_error'(type_error(variable, Id), message_queue_create(Id))
; '$do_error'(uninstantiation_error(Id), message_queue_create(Id))
).
'$do_msg_queue_create'(Id) :-

View File

@ -22,7 +22,7 @@ open(Source,M,T) :- var(Source), !,
open(Source,M,T) :- var(M), !,
'$do_error'(instantiation_error,open(Source,M,T)).
open(Source,M,T) :- nonvar(T), !,
'$do_error'(type_error(variable,T),open(Source,M,T)).
'$do_error'(uninstantiation_error(T),open(Source,M,T)).
open(File0,Mode,Stream) :-
'$default_encoding'(Encoding),
'$default_expand'(Expansion),
@ -76,7 +76,7 @@ open(F,T,S,Opts) :-
'$open2'(Source,M,T,N,_,_) :- var(M), !,
'$do_error'(instantiation_error,open(Source,M,T,N)).
'$open2'(Source,M,T,N,_,_) :- nonvar(T), !,
'$do_error'(type_error(variable,T),open(Source,M,T,N)).
'$do_error'(uninstantiation_error(T),open(Source,M,T,N)).
'$open2'(File, Mode, Stream, N, Encoding, F0) :-
'$open'(File, Mode, Stream, N, Encoding, F0).