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

etebase_client_new throw ETEBASE_ERROR_CODE_MSG_PACK #3

Closed
knacky34 opened this issue May 19, 2021 · 3 comments
Closed

etebase_client_new throw ETEBASE_ERROR_CODE_MSG_PACK #3

knacky34 opened this issue May 19, 2021 · 3 comments

Comments

@knacky34
Copy link

I trying to implement Etebase on my application but I'm getting stuck on etebase_client_new function which throws ETEBASE_ERROR_CODE_MSG_PACK.
I would know in which case this exception is thrown ?
Also, I would know what is the purpose of the first argument const char *client_name of the function ?

Here is my code :

EtebaseErrorCode EteSync::createClient(std::string &customServerUrl, EtebaseClient **client) {
    const char *serverUrl = serverUrl.empty() ? etebase_get_default_server_url() : customServerUrl.c_str();

    *client = etebase_client_new("client", serverUrl);
    EtebaseErrorCode err = etebase_error_get_code();
    if (err != ETEBASE_ERROR_CODE_NO_ERROR) {
        return err;
    }

    ...

    return ETEBASE_ERROR_CODE_NO_ERROR;
}

Thank you

@tasn
Copy link
Member

tasn commented May 19, 2021

client_name: should be for error messages, but also user agent for the http request.
msgpack error: means that serializing (or more likely deserializing) the request failed. Most likely because it's not actually an etebase server you are connecting to.

Also, the code is wrong. You should only check the error code if client is NULL. If the previous function did not return null, the value of err is undefined.

@knacky34
Copy link
Author

Thank you for your answer !
I'm currently working on an API reference, only for C/C++ for now. I will modify the doc according to your comment.

So, it would be nice if we could work together to develop this API reference, because for example it's almost impossible for me to know what exceptions could throw a function because I have to guess it. I've opened a pull request etebase-docs#27

@tasn
Copy link
Member

tasn commented May 21, 2021

Exceptions: that's a bit opaque at the moment (not documented).

Anyhow, I'm closing this ticket as the issue is solved. Let's talk in the PR.

@tasn tasn closed this as completed May 21, 2021
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

2 participants