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(
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) => {
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")
+ )
+ }
}
}
ModuleNotFound,
NamelessEntry,
OpIsInfixAndPostFix(ClauseName),
+ QueryCannotBePostedAsGoal,
ParserError(ParserError),
}
TopLevel::Declaration(decl) =>
return Ok(Some(decl)),
TopLevel::Query(_) =>
- return Err(SessionError::NamelessEntry),
+ return Err(SessionError::QueryCannotBePostedAsGoal),
}
}
impl fmt::Display for SessionError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
- &SessionError::CannotOverwriteBuiltIn(ref msg) => write!(f, "cannot overwrite {}", msg),
+ &SessionError::CannotOverwriteBuiltIn(ref msg) => {
+ write!(f, "cannot overwrite {}", msg)
+ }
&SessionError::CannotOverwriteImport(ref msg) => {
write!(f, "cannot overwrite import {}", msg)
}
&SessionError::NamelessEntry => {
write!(f, "the predicate head is not an atom or clause.")
}
- &SessionError::ParserError(ref e) => write!(f, "syntax_error({})", e.as_str()),
+ &SessionError::ParserError(ref e) => {
+ write!(f, "syntax_error({})", e.as_str())
+ }
+ &SessionError::QueryCannotBePostedAsGoal => {
+ write!(f, "query forms cannot be posted as goals.")
+ }
}
}
}