$I = \int_{- \infty}^\infty \delta (n - \|\mathbf{x}\|^2) \, \mathrm d \mathbf{x} $ should not diverge I'm having trouble evaluating this integral:
$$I = \int_{-\infty}^\infty \delta (n - \|\mathbf{x}\|^2) \,\mathrm d \mathbf{x} $$
where $\delta(x)$ is Dirac delta function, $\mathbf x$ is the real $n$-dimensional vector $(x_1,\ldots,x_n)$, and $\|\mathbf{x}\|^2 = \sum_{i=1}^n x_i^2$. Here I use the short-hand notation:
$$\int_{-\infty}^\infty\mathrm d \mathbf{x} = \int_{-\infty}^\infty\mathrm d x_1 \cdots \int_{-\infty}^\infty\mathrm d x_n$$
Here is what I tried to do. Using the integral representation of Dirac's delta function $\delta (x) = \int_{- \infty}^{\infty} \frac{d \lambda}{2 \pi} e^{i \lambda x}$, I get
$$I = \int_{- \infty}^\infty d \mathbf{x} \int_{-\infty}^\infty
\frac{d\lambda}{2\pi} \mathrm e^{i\lambda(n - \| \mathbf{x} \|^2)} = \int_{- \infty}^\infty \frac{d\lambda}{2\pi} e^{-i \lambda n} \left( \int_{- \infty}^\infty e^{i\lambda x^2} \, dx \right)^n$$
I evaluated the inner integral with Mathematica:
$$\int_{- \infty}^{\infty} e^{i\lambda x^2} \, dx = \sqrt{\frac{\pi}{2}} \frac{1 +i \operatorname{sgn}(\lambda)}{\sqrt{|\lambda|}}$$
But then when I try to substitute this I get a diverging integral in $\lambda$.
What did I do wrong?
Note that the original integral is well behaved. Using polar coordinates it can be shown that $I = n^{n/2-1} \pi^{n/2} / \Gamma(n/2)$ (see  https://doi.org/10.1093/qmath/12.1.165, or my answer below). Some step of my derivation leads to a fictitious divergence.
Update: @user587192's answer found the error in my calculation. I cannot exchange the order of integrations on $x$ and $\lambda$. My next question is whether there is a way to rescue this calculation? Manipulations with the Fourier transform of the Dirac delta are very convenient in more complicated situations. This is evident from the algebraic complexity of the spherical coordinates appraoch. Is there way to exploit the convenience of the Fourier representation of the Dirac delta here?

Here is the solution in (hyper)spherical coordinates, proving that $I$ should be well behaved. The spherical coordinates are defined by:
$$x_1 = r \cos(\phi_1),\quad x_2 = r \sin(\phi_1)\cos(\phi_2),\dots,\quad x_n = r \sin(\phi_1)\dots\sin(\phi_{n-2})\sin(\theta)$$
where $0\le\phi_i\le\pi$, $0\le\theta\le2\pi$ and $0\le r<\infty$. The volume element is then:
$$\mathrm d x_1 \dots \mathrm d x_n = r^{n-1}\sin^{n-2}(\phi_1)\dots\sin(\phi_{n-2}) \mathrm dr \mathrm d\phi_1\dots\mathrm d\phi_{n-2}\mathrm d\theta$$
We have:
$$\begin{aligned}
  I & = \int_{\mathbb{R}^n} \delta (n - \| \mathbf{x} \|^2) \mathrm d
  \mathbf{x}\\
  & = \int_0^{\pi} \mathrm d \phi_1 \ldots \int_0^{\pi}\mathrm d \phi_{n - 2} \int_0^{2 \pi}
  \mathrm d \theta \int_0^{\infty} \mathrm d r \, \delta (n - r^2) r^{n - 1} \sin^{n -
  2} (\phi_1) \ldots \sin (\phi_{n - 2})\\
  & = \left( \int_0^{\infty} \delta (n - r^2) r^{n - 1} \mathrm d r \right)
  \left( \int_0^{2 \pi} \mathrm d \theta \mathrm d \theta \right) \left(
  \int_0^{\pi} \sin^{n - 2} (\phi_1) \mathrm d \phi_1 \right) \ldots \left(
  \int_0^{\pi} \sin (\phi_{n - 2}) \mathrm d \phi_{n - 2} \right)\\
  & = \frac{\pi^{n / 2} n^{n / 2 - 1}}{\Gamma (n / 2)}
\end{aligned}$$
This is not an answer to my question. My question is: What did I do wrong to that leads to a divergent integral?
