web: predeclare and reuse errors (#5180)
web: predeclare and reuse errors (#5180)

Predeclare and reuse errors to reduce duplicate code

Signed-off-by: zhulongcheng <d0a909104c54f7c1064d09716f840641c5a2a6f9@gmail.com>
keegancsmith/prometheus,kangwoo/prometheus,alileza/prometheus,alileza/prometheus,GoogleCloudPlatform/prometheus,alileza/prometheus,GoogleCloudPlatform/prometheus,keegancsmith/prometheus,prometheus/prometheus,GoogleCloudPlatform/prometheus,Gouthamve/prometheus,GoogleCloudPlatform/prometheus,keegancsmith/prometheus,alileza/prometheus,Gouthamve/prometheus,prometheus/prometheus,Gouthamve/prometheus,alileza/prometheus,keegancsmith/prometheus,kangwoo/prometheus,kangwoo/prometheus,prometheus/prometheus,Gouthamve/prometheus,prometheus/prometheus,kangwoo/prometheus,prometheus/prometheus,GoogleCloudPlatform/prometheus,keegancsmith/prometheus