Skip to content

Commit fdae674

Browse files
committed
Init exception handling
1 parent c9dce78 commit fdae674

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

ext/symengine/ruby_basic.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,26 @@ VALUE cbasic_mul(VALUE self, VALUE operand2)
7373

7474
VALUE cbasic_div(VALUE self, VALUE operand2)
7575
{
76-
return cbasic_binary_op(self, operand2, basic_div);
76+
basic_struct *this, *cresult;
77+
VALUE result;
78+
79+
basic cbasic_operand2;
80+
basic_new_stack(cbasic_operand2);
81+
82+
Data_Get_Struct(self, basic_struct, this);
83+
sympify(operand2, cbasic_operand2);
84+
85+
cresult = basic_new_heap();
86+
int error_code = basic_div(cresult, this, cbasic_operand2);
87+
88+
if (error_code == 0) {
89+
result = Data_Wrap_Struct(Klass_of_Basic(cresult), NULL,
90+
cbasic_free_heap, cresult);
91+
basic_free_stack(cbasic_operand2);
92+
return result;
93+
} else {
94+
rb_raise(rb_eRuntimeError, "Runtime Error");
95+
}
7796
}
7897

7998
VALUE cbasic_pow(VALUE self, VALUE operand2)

0 commit comments

Comments
 (0)