Skip to content

Commit 475c460

Browse files
authored
Merge pull request #68 from constraintAutomaton/fix/reporting-validation-error
Error message in the terminal added for validation error
2 parents dfd4afc + b23bc65 commit 475c460

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/bakage.pl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@
126126
append([RootChars, "/scryer_libs"], ScryerPath)
127127
).
128128

129-
% the message sent to the user when a dependency is malformed
130-
user_message_malformed_dependency(D, Error):-
131-
current_output(Out),
132-
phrase_to_stream((portray_clause_(D), "is malformed: ", Error, "\n"), Out).
133129

134130
% A prolog file knowledge base represented as a list of terms
135131
prolog_kb_list(Stream) --> {read(Stream, Term), dif(Term, end_of_file)}, [Term], prolog_kb_list(Stream).

src/validation.pl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,31 @@
104104

105105
).
106106

107+
% the message sent to the user when a dependency is malformed
108+
user_message_malformed_dependency(D, Error):-
109+
current_output(Out),
110+
phrase_to_stream((portray_clause_(D), "is malformed: ", Error, "\n"), Out).
111+
112+
% the message sent to the user when there is a validation error
113+
user_message_invalid_manifest(Error):-
114+
current_output(Out),
115+
phrase_to_stream(("The installation failed; cause:\n\t", Error, "\n"), Out).
116+
107117
% Is valid when there is 0 instance and the field is optional
108118
has_a_field([], _, _, true, success).
109119

110120
% Is not valid when there is 0 instance and the field is not optional
111121
has_a_field([], FieldName, PredicateForm, false, error(Es)):-
112-
phrase(format_("the '~s' of the package is not defined or does not have the a predicate of the form '~s'", [FieldName, PredicateForm]), Es).
122+
phrase(format_("the '~s' of the package is not defined or does not have the a predicate of the form '~s'", [FieldName, PredicateForm]), Es),
123+
user_message_invalid_manifest(Es).
113124

114125
% Is valid when there is one instance of the field and the field value has the correct type
115126
has_a_field([_], _, _, _, success).
116127

117128
% Is not valid when there are multiple instances of the field
118129
has_a_field([_,_|_], FieldName, _, _, error(Es)):-
119-
phrase(format_("the package has multiple '~s'", [FieldName]), Es).
130+
phrase(format_("the package has multiple '~s'", [FieldName]), Es),
131+
user_message_invalid_manifest(Es).
120132

121133
has_valid_name(Manifest, Result):-
122134
phrase(pattern_in_list(Manifest, name_t), S),

0 commit comments

Comments
 (0)