I have a SP with rule/logic which does the calculations. when i run the SP sometimes it throws divide by zero some times it doesn't.
Since we don't see the code, it will have to be a bit of speculation. But I will assume that there are conditions that filters out the three problematic rows, so that they are not part of the result being returned.
In this case, ideally, there should not be any exception at all, since logically there is no error. However, depending on the query plan SQL Server may filter first and then compute the division, or it may divide before filtering. When composing the query plan, the optimizer does not consider that an operation can fail and take precautions accordingly. So therefore the query can fail even if the bad rows are logically filtered out.
A common way to avoid this is to write divisions like val1/nullif(val2, 0)
, so that you get a NULL for the division.