Initial error refactor

This commit is contained in:
Marcin Mielniczuk
2019-09-07 19:36:29 +02:00
committed by Jakub Konka
parent 85a41d449c
commit 14aaffd46f
22 changed files with 560 additions and 383 deletions

View File

@@ -3,7 +3,7 @@
//! still largely reflects that.
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::Result;
use crate::{Error, Result};
use std::{io, slice, str};
pub type void = ::std::os::raw::c_void;
@@ -500,7 +500,7 @@ pub unsafe fn iovec_to_host_mut<'a>(iovec: &'a mut __wasi_iovec_t) -> io::IoSlic
/// NB WASI spec requires bytes to be valid UTF-8. Otherwise,
/// `__WASI_EILSEQ` error is returned.
pub fn path_from_slice<'a>(s: &'a [u8]) -> Result<&'a str> {
str::from_utf8(s).map_err(|_| __WASI_EILSEQ)
str::from_utf8(s).map_err(|_| Error::EILSEQ)
}
/// Creates owned WASI path from byte vector.
@@ -508,7 +508,7 @@ pub fn path_from_slice<'a>(s: &'a [u8]) -> Result<&'a str> {
/// NB WASI spec requires bytes to be valid UTF-8. Otherwise,
/// `__WASI_EILSEQ` error is returned.
pub fn path_from_vec<S: Into<Vec<u8>>>(s: S) -> Result<String> {
String::from_utf8(s.into()).map_err(|_| __WASI_EILSEQ)
String::from_utf8(s.into()).map_err(|_| Error::EILSEQ)
}
#[cfg(test)]