Skip to content

About calling a runtime_error what() function {UTFreamwork} #10

@alshakh

Description

@alshakh

This issue is to continue the descussion about UTFreamwork changes.

The changes were :

cppFine Line(155)

void UTFramework::FaultException(std::exception exeption )
will be :
void UTFramework::FaultException(const std::exception& exeption )

hFile Line(97)

static void FaultException (std::exception exeption );
will be :
static void FaultException (const std::exception& exeption );

I tried a code like this.

#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include "UTFramework.h"
using namespace std;
using namespace Thilenius;

SUITE_BEGIN("Suite!")

TEST_BEGIN("Test") {
    throw runtime_error("Message");
}

TEST_END

SUITE_END


int main() {
    UTFrameworkInit;
}

Without the changes, the result was std::exception. When I tried the changes, the result was Message.

Ahmed

Quote(Alec Thilenius )

To answer your comment, that is because a runtime error is not an std::exception. I 'think' that they are both children of the exception object, but I am not sure about that one. For my own curiosity could you please send me the code that generated a runtime error? I may add it to the framework as a supported type.

Quote(Ahmed Alshakh)

I don't know why I can't see your comment here, but I can see it on the updates. I don't really know how to use git. Sorry..
I made the change because when I tried to throw a "runtime_error" UTFreamework showed "std::exception" not my message. I played with it for long time until it worked. I am not sure this is the right change but It worked for me.

Quote(Alec Thilenius )

Could you please elaborate on why you made this change? Passing by value is fine, and had been tested.

Quote(Ahmed Alshakh )

The function FaultException() should get the exception by reference not by value in order to show e.what() instead of std::exception

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions