diff --git a/src/nl_to_polynomial.jl b/src/nl_to_polynomial.jl
index 8a0d8cd..44704fe 100644
--- a/src/nl_to_polynomial.jl
+++ b/src/nl_to_polynomial.jl
@@ -109,10 +109,12 @@ function _checked_div(
     b::DynamicPolynomials.Variable,
 )
     divisor, remainder = Base.divrem(a, b)
-    if iszero(remainder)
-        return divisor
+    if !iszero(remainder)
+        throw(
+            InvalidNLExpression("Cannot convert `$(a) / $b` into a polynomial"),
+        )
     end
-    return a / b
+    return divisor
 end
 
 function _to_polynomial(expr, ::Type{T}) where {T}
diff --git a/test/qcqp.jl b/test/qcqp.jl
index c1b5990..0ffa37e 100644
--- a/test/qcqp.jl
+++ b/test/qcqp.jl
@@ -231,9 +231,21 @@ function test_scalar_nonlinear_function_div_rem_zero(x, y, T)
     return
 end
 
-test_scalar_nonlinear_function_div_rem_one(x, y, ::Type{Int}) = nothing
+function test_scalar_nonlinear_function_div_rem_err(x, y, T)
+    inner = Model{T}()
+    model = PolyJuMP.JuMP.GenericModel{T}() do
+        return PolyJuMP.QCQP.Optimizer{T}(MOI.Utilities.MockOptimizer(inner))
+    end
+    PolyJuMP.@variable(model, x)
+    PolyJuMP.@variable(model, y)
+    PolyJuMP.@objective(model, Min, x^3 / y)
+    @test_throws PolyJuMP.InvalidNLExpression PolyJuMP.optimize!(model)
+    return
+end
+
+test_scalar_nonlinear_function_div_rem_number(x, y, ::Type{Int}) = nothing
 
-function test_scalar_nonlinear_function_div_rem_one(x, y, T)
+function test_scalar_nonlinear_function_div_rem_number(x, y, T)
     inner = Model{T}()
     model = PolyJuMP.JuMP.GenericModel{T}() do
         return PolyJuMP.QCQP.Optimizer{T}(MOI.Utilities.MockOptimizer(inner))