This is starting to be a party of solutions! There are several monadic solutions to this problem beyond the Option/Maybe monad suggested by Bjørn. Perhaps monads aren't that scary to people around here but I will nevertheless explain the idea plainly, focusing on the underlying mathematics first rather than on the computer science.
To make this concrete, let's look at this equation:
$$\frac{x^2 - y^2}{x+y} = x-y$$
This is evidently true but when we do that we implicitly ignore the problematic case where $x+y=0$. There is no type theory that I know which includes "implicitly ignoring". So we have to look a bit deeper into what we really mean by the equation above.
The first step is to think about what $x$ and $y$ mean. The key is to think of them as projections. Without any further constraints or additional context, we can think of $x$ and $y$ as the first- and second-coordinate projections $\mathbb{Q}^2 \to \mathbb{Q}$. Then an equation like $x + y = y + x$ is simply a map from $\mathbb{Q}^2\to\mathsf{Prop}$, and a proof of this identity is a proof that this is the constant map with value true. This allows us to easily make sense of any total operations like addition, multiplication, negation.
We can also make sense of division in this way but we need to enrich the context. Our equation
$$\frac{x^2 - y^2}{x+y} = x-y$$
doesn't make sense as a function from $\mathbb{Q}\times\mathbb{Q}\to\mathsf{Prop}$. However, there is a two-dimensional variety over which it makes perfect sense, namely the variety
$$V = \{(x,y,z) \in \mathbb{Q}^3 \mid (x+y)z = 1\}$$
If we think of $x$ and $y$ as the first- and second-coordinate projections $V \to \mathbb{Q}$ then
$$\frac{x^2 - y^2}{x+y} = x-y$$
makes perfect sense and a proof of this identity is a proof that this equation defines a constant map $V \to \mathsf{Prop}$ with value true.
Where's the monad? It's in the variety $V$. This is known as a Reader monad. In general, the Reader monad is used to share an environment or context between values. In this case, the shared context is the variety $V$ and $x,y,z$ are not values but maps $V \to \mathbb{Q}$. A proof assistant with strong support for monads can automate keeping track of the contextual variety $V$ and can make large parts of this process relatively seamless.
Besides being correct, there are some advantages to working with such monads. To an algebraist, the question whether
$$\frac{x^2 - y^2}{x+y} = x-y$$
is true on the variety $V$ probably wouldn't be a direct proof that this is a constant function. Rather, the algebraist would probably ask whether the congruence
$$(x^2-y^2)z \equiv x - y$$
holds modulo the ideal generated by $(x+y)z - 1 = 0$. There are many sophisticated tools available to automate this type of questions...
Q → (Σ(q:Q) q≠0) → Q
is binary and can be used as an infix operator. (I am just teasing.) $\endgroup$Q → (q : Q) → q ≠ 0 → Q
is binary as well, it's just that it doesn't return a number. (Still teasing, sorry I couldn't help myself.) $\endgroup$