Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected in ICore create methods #93

Open
xxshady opened this issue Jan 18, 2024 · 0 comments
Open

Expected in ICore create methods #93

xxshady opened this issue Jan 18, 2024 · 0 comments

Comments

@xxshady
Copy link
Contributor

xxshady commented Jan 18, 2024

Currently SDK returns nullptr if it fails to create some base object, in some cases not even printing reason of it to console.

Suggestion

Make use of Expected in ICore base objects create methods, so modules implementing alt:V API can provide more info right in code to server developers.

Rust API example (Rust's Result<Ok, Err> is very similar to Expected type in SDK)

let result = altv::VoiceChannel::new(...);
match (result) {
  Ok(channel) => {
    // ...
  }
  Err(altv::VoiceChannelCreationError::VoiceChatIsNotEnabled) => {
    // ...
  }
}

SDK example

auto expected = alt::ICore::Instance().CreateVoiceChannel(...);

if(expected.success) {
    // using expected.value
} else {
  switch(expected.error) {
    case alt::VoiceChannelCreationError::VoiceChatIsNotEnabled:
      // ...
      break;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant