Convert ffi/ to failure.

This is neat, because currently at the FFI boundary we're primarily concerned
with verbalizing our errors. It doesn't matter what 'error' that's wrapped by
Result is then, as long as it can be displayed.

Once we're past the prototyping stage, it might be a good idea to formalize this.
This commit is contained in:
Grisha Kruglov 2018-06-04 20:10:46 -04:00 committed by Nick Alexander
parent 4e01929334
commit 800f404a23
2 changed files with 4 additions and 38 deletions

View file

@ -67,9 +67,12 @@
//! propogation. These types have implemented [From](std::convert::From) such that conversion from the Rust type
//! to the C type is as painless as possible.
extern crate core;
extern crate libc;
extern crate mentat;
use core::fmt::Display;
use std::collections::{
BTreeSet,
};
@ -204,7 +207,7 @@ pub struct ExternResult {
pub err: *const c_char,
}
impl<T, E> From<Result<T, E>> for ExternResult where E: std::error::Error {
impl<T, E> From<Result<T, E>> for ExternResult where E: Display {
fn from(result: Result<T, E>) -> Self {
match result {
Ok(value) => {

View file

@ -1,37 +0,0 @@
// 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.
#![allow(dead_code)]
use rusqlite;
use mentat::errors as mentat;
error_chain! {
types {
Error, ErrorKind, ResultExt, Result;
}
foreign_links {
Rusqlite(rusqlite::Error);
IoError(::std::io::Error);
}
links {
MentatError(mentat::Error, mentat::ErrorKind);
}
errors {
CommandParse(message: String) {
description("An error occured parsing the entered command")
display("{}", message)
}
}
}