Pre: add mentat_query_algebrizer::errors.

This commit is contained in:
Richard Newman 2017-03-16 19:16:56 +00:00
parent d8d36140a9
commit f5aa6b2c2c
4 changed files with 55 additions and 3 deletions

View file

@ -4,6 +4,8 @@ version = "0.0.1"
workspace = ".."
[dependencies]
error-chain = "0.9.0"
[dependencies.mentat_core]
path = "../core"

View file

@ -14,8 +14,8 @@ extern crate mentat_query;
use std::fmt::{
Debug,
Formatter,
Result,
};
use std::collections::{
BTreeMap,
BTreeSet,
@ -39,6 +39,12 @@ use self::mentat_query::{
Variable,
};
use errors::{
Error,
ErrorKind,
Result,
};
use types::{
DatomsColumn,
DatomsTable,
@ -192,7 +198,7 @@ pub enum EmptyBecause {
}
impl Debug for EmptyBecause {
fn fmt(&self, f: &mut Formatter) -> Result {
fn fmt(&self, f: &mut Formatter) -> ::std::fmt::Result {
use self::EmptyBecause::*;
match self {
&TypeMismatch(ref var, ref existing, ref desired) => {
@ -223,7 +229,7 @@ impl Debug for EmptyBecause {
}
impl Debug for ConjoiningClauses {
fn fmt(&self, fmt: &mut Formatter) -> Result {
fn fmt(&self, fmt: &mut Formatter) -> ::std::fmt::Result {
fmt.debug_struct("ConjoiningClauses")
.field("is_known_empty", &self.is_known_empty)
.field("from", &self.from)

View file

@ -0,0 +1,40 @@
// Copyright 2016 Mozilla
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
extern crate mentat_query;
use self::mentat_query::{
PlainSymbol,
Variable,
};
error_chain! {
types {
Error, ErrorKind, ResultExt, Result;
}
errors {
UnknownFunction(name: PlainSymbol) {
description("no such function")
display("no function named {}", name)
}
InvalidNumberOfArguments(name: PlainSymbol, number: usize, expected: usize) {
description("invalid number of arguments")
display("invalid number of arguments to {}: expected {}, got {}.", name, expected, number)
}
UnboundVariable(var: Variable) {
description("unbound variable in function call")
display("unbound variable: {}", var.0)
}
}
}

View file

@ -8,9 +8,13 @@
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
#[macro_use]
extern crate error_chain;
extern crate mentat_core;
extern crate mentat_query;
mod errors;
mod types;
mod cc;