From 800f404a23a5102771d8f0d68bcf9bf0f1b9d1ac Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Mon, 4 Jun 2018 20:10:46 -0400 Subject: [PATCH] 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. --- ffi/src/lib.rs | 5 +++- tools/cli/src/mentat_cli/errors.rs | 37 ------------------------------ 2 files changed, 4 insertions(+), 38 deletions(-) delete mode 100644 tools/cli/src/mentat_cli/errors.rs diff --git a/ffi/src/lib.rs b/ffi/src/lib.rs index 7e8eaa49..a665b25a 100644 --- a/ffi/src/lib.rs +++ b/ffi/src/lib.rs @@ -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 From> for ExternResult where E: std::error::Error { +impl From> for ExternResult where E: Display { fn from(result: Result) -> Self { match result { Ok(value) => { diff --git a/tools/cli/src/mentat_cli/errors.rs b/tools/cli/src/mentat_cli/errors.rs deleted file mode 100644 index 0012c319..00000000 --- a/tools/cli/src/mentat_cli/errors.rs +++ /dev/null @@ -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) - } - } -}