throw exception when attempting to post query as goal (#329)

This commit is contained in:
Mark Thom
2020-04-12 12:07:41 -06:00
parent 97d8d07947
commit 5e81fb4754
3 changed files with 31 additions and 8 deletions

View File

@@ -301,9 +301,6 @@ impl MachineError {
pub(super)
fn session_error(h: usize, err: SessionError) -> Self {
match err {
SessionError::ParserError(err) => {
Self::syntax_error(h, err)
}
SessionError::CannotOverwriteBuiltIn(pred_str)
| SessionError::CannotOverwriteImport(pred_str) => {
Self::permission_error(
@@ -329,7 +326,15 @@ impl MachineError {
h,
Permission::Access,
"private_procedure",
functor!("modules_does_not_exist"),
functor!("module_does_not_exist"),
)
}
SessionError::NamelessEntry => {
Self::permission_error(
h,
Permission::Create,
"static_procedure",
functor!("nameless_procedure")
)
}
SessionError::OpIsInfixAndPostFix(op) => {
@@ -340,7 +345,17 @@ impl MachineError {
functor!(clause_name(op)),
)
}
_ => unreachable!(),
SessionError::ParserError(err) => {
Self::syntax_error(h, err)
}
SessionError::QueryCannotBePostedAsGoal => {
Self::permission_error(
h,
Permission::Create,
"static_procedure",
functor!("query_cannot_be_posted_as_goal")
)
}
}
}
@@ -681,6 +696,7 @@ pub enum SessionError {
ModuleNotFound,
NamelessEntry,
OpIsInfixAndPostFix(ClauseName),
QueryCannotBePostedAsGoal,
ParserError(ParserError),
}

View File

@@ -1290,7 +1290,7 @@ impl<'a> TopLevelBatchWorker<'a> {
TopLevel::Declaration(decl) =>
return Ok(Some(decl)),
TopLevel::Query(_) =>
return Err(SessionError::NamelessEntry),
return Err(SessionError::QueryCannotBePostedAsGoal),
}
}