Sign in to follow this  

Getting rid of Angelscript prints

This topic is 1508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello!

 

I want to do my own error handling for when Angelscript functions fail. In most cases this is really easy by just checking the return value. However it seems like there is one case where I am getting an error print from Angelscript when I would rather want to take care of it myself. Here is the code in question:

 

asIObjectType* ScriptModule::getObjectTypeByDecl(const std::string& decl)
{
    std::cout << "Type declaration: " << decl << "\n";
    auto id = mAsModule->GetTypeIdByDecl(decl.c_str());
    std::cout << "Id: " << id << "\n";


    if(id < 0)
    {   
        std::cout << "Returning null!\n";
        return nullptr;
    }   


    auto thing = mEngine.getEngine()->GetObjectTypeById(id);
    std::cout << "Thing is: " << thing << "\n";


    return thing;
}

If I provide this function with a type that does not exist, "Elphant" instead of "Elephant" for instance, I get the following output:

 

Type declaration: Elphant
 (1, 1) : error : Identifier 'Elphant' is not a data type
Id: -12
Returning null!

So it seems like everything works as expected, except that the function not only returns -12 as the error, but also gives this debug print which is unwanted. Is there a particular reason for this? Am I doing it the wrong way? If not, can I get rid of the print somehow?

 

Share this post


Link to post
Share on other sites

This topic is 1508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this