Skip to content

Commit 987bc03

Browse files
committed
fuck
1 parent 5308766 commit 987bc03

File tree

6 files changed

+16
-20
lines changed

6 files changed

+16
-20
lines changed

crates/byondapi-macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "byondapi-macros"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2021"
55
description = "Macros for byondapi"
66
license = "MIT"

crates/byondapi-macros/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ pub fn bind(attr: TokenStream, item: TokenStream) -> TokenStream {
129129
match #func_name(#proc_arg_unpacker) {
130130
Ok(val) => val,
131131
Err(e) => {
132-
let error_string = ::byondapi::value::ByondValue::try_from(e.0).unwrap();
132+
let error_string = ::byondapi::value::ByondValue::try_from(::std::format!("{e:?}")).unwrap();
133133
::byondapi::global_call::call_global_id(byond_string!("stack_trace"), &[error_string]).unwrap();
134134
::byondapi::value::ByondValue::null()
135135
}
136136
}
137137

138138
}
139-
fn #func_name(#args) -> Result<::byondapi::value::ByondValue, ::byondapi::BindError>
139+
fn #func_name(#args) -> Result<::byondapi::value::ByondValue, ::byondapi::Error>
140140
#body
141141
};
142142
result.into()
@@ -231,13 +231,13 @@ pub fn bind_raw_args(attr: TokenStream, item: TokenStream) -> TokenStream {
231231
match #func_name(args) {
232232
Ok(val) => val,
233233
Err(e) => {
234-
let error_string = ::byondapi::value::ByondValue::try_from(e.0).unwrap();
234+
let error_string = ::byondapi::value::ByondValue::try_from(::std::format!("{e:?}")).unwrap();
235235
::byondapi::global_call::call_global_id(byond_string!("stack_trace"), &[error_string]).unwrap();
236236
::byondapi::value::ByondValue::null()
237237
}
238238
}
239239
}
240-
fn #func_name(args: &mut [::byondapi::value::ByondValue]) -> Result<::byondapi::value::ByondValue, ::byondapi::BindError>
240+
fn #func_name(args: &mut [::byondapi::value::ByondValue]) -> Result<::byondapi::value::ByondValue, ::byondapi::Error>
241241
#body
242242
};
243243
result.into()

crates/byondapi-rs-test/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ fn test_list_pop(mut list: ByondValue) {
9191
let element = list.pop_list()?;
9292

9393
if list.builtin_length()?.get_number()? as u32 != 4 {
94-
return Err(eyre::eyre!("pop did not actually remove item from list").into());
94+
return Err(byondapi::Error::BindError(format!(
95+
"pop did not actually remove item from list"
96+
)));
9597
}
9698

9799
Ok(element.unwrap())
@@ -113,7 +115,10 @@ fn test_block() {
113115
)?;
114116

115117
if block.len() != 4 {
116-
return Err(eyre::eyre!("block returned {} turfs when we expected 4", block.len()).into());
118+
return Err(byondapi::Error::BindError(format!(
119+
"block returned {} turfs when we expected 4",
120+
block.len()
121+
)));
117122
}
118123

119124
Ok((block.len() as f32).into())

crates/byondapi-rs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "byondapi"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
authors = ["tigercat2000 <[email protected]>"]
55
edition = "2021"
66
description = "Idiomatic Rust bindings for BYONDAPI"

crates/byondapi-rs/src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ pub enum Error {
3232
NonExistentString(CString),
3333
/// Thrown when we know byondland failed to create a string
3434
UnableToCreateString(CString),
35+
/// Custom error type thrown by binds
36+
BindError(String),
3537
}
3638

3739
impl Error {
@@ -67,6 +69,7 @@ impl std::fmt::Display for Error {
6769
Self::UnableToCreateString(string) => {
6870
write!(f, "Unable to create string \"{string:#?}\"")
6971
}
72+
Self::BindError(string) => write!(f, "{string}"),
7073
}
7174
}
7275
}

crates/byondapi-rs/src/lib.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,6 @@ inventory::collect!(InitFunc);
4848
///Or add a #[byondapi::init] attribute to a function
4949
pub struct InitFunc(pub fn() -> ());
5050

51-
///Custom error type for binds, just to implement From for ?
52-
pub struct BindError(pub String);
53-
54-
impl<E> From<E> for BindError
55-
where
56-
E: std::fmt::Debug,
57-
{
58-
fn from(value: E) -> Self {
59-
BindError(format!("{value:#?}"))
60-
}
61-
}
62-
6351
///This macro caches string ids and returns it instead of doing a stringid lookup everytime
6452
///The macro will panic if the string doesn't already exist on byond init lib
6553
///Example usage:

0 commit comments

Comments
 (0)