We discuss a possible extension of calculations of the bending angle of light in a static, spherically symmetric and asymptotically flat spacetime to a non-asymptotically flat case. We examine a relation between the bending angle of light and the Gauss-Bonnet theorem by using the optical metric. A correspondence between the deflection angle of light and the surface integral of the Gaussian curvature may allow us to take account of the finite distance from a lens object to a light source and a receiver. Using this relation, we propose a method for calculating the bending angle of light for such cases. Finally, this method is applied to two examples of the non-asymptotically flat spacetimes to suggest finite-distance corrections: Kottler (Schwarzschild-de Sitter) solution to the Einstein equation and an exact solution in Weyl conformal gravity.