Restructure error handling and remove duplication
Restructure error handling and remove duplication: a task in Trending-SWE1.0 (Harbor dataset). Title: Restructure error handling and remove duplication
The task
**Title:** Restructure error handling and remove duplication
Part of scalingX/Trending-SWE1.0.