Skip to content

Conversation

@rajithv
Copy link
Contributor

@rajithv rajithv commented Jul 23, 2016

An example with cbasic_div method.

return result;
} else {
basic_free_stack(cbasic_operand2);
rb_raise(rb_eRuntimeError, "Runtime Error");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this error signify? The error message should be more descriptive than "Runtime Error", which does not give much information about what's actually going wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@v0dro this is in place until a exceptions are made in the SymEngine C++ code (right now it's all std::runtime_errors). Anyway I have written the code to be integrated into the cwrappers to catch multiple exceptions (for a method like parse this is needed). Then depending on the error code sent, the suitable error message will be displayed. This is still WIP. Please check symengine/symengine#1044 for the discussion on this :)

} else {
basic_free_stack(cbasic_operand1);
basic_free_stack(cbasic_operand2);
rb_raise(rb_eRuntimeError, "Runtime Error");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use raise_exception here.

@rajithv rajithv force-pushed the exception branch 4 times, most recently from 45c9334 to 62351d1 Compare August 16, 2016 15:04
basic_free_stack(cbasic_operand2);
int error_code = cwfunc_ptr(cresult, cbasic_operand1, cbasic_operand2);

if (error_code == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of 0, check for SYMENGINE_NO_EXCEPTION

@isuruf
Copy link
Member

isuruf commented Aug 17, 2016

Can you add some tests in ruby?

cresult);
basic_free_stack(cbasic_operand2);

int error_code = cwfunc_ptr(cresult, this, cbasic_operand2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to use the enum for error codes here.

result = Data_Wrap_Struct(Klass_of_Basic(cresult), NULL, cbasic_free_heap,
cresult);

symengine_exceptions_t error_code = cwfunc_ptr(cresult, this);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use one convention. int or symengine_exceptions_t or CWRAPPER_OUTPUT_TYPE. All 3 are used in this PR.

@rajithv rajithv changed the title [WIP] Exception Handling Exception Handling Aug 19, 2016
@isuruf isuruf merged commit eed5f42 into symengine:master Aug 21, 2016
@isuruf
Copy link
Member

isuruf commented Aug 21, 2016

Thanks for the PR.

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

Successfully merging this pull request may close these issues.

4 participants