mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-27 17:50:53 +01:00
fix: improve error handling and enhance setting management
- Updated error handling in GetSetting to use errors.Is for better clarity when checking for no documents. - Refactored setting retrieval in the Vuex store to ensure a default value is set if the retrieved setting is empty. - Adjusted API calls in the store to wrap payloads in a data object for consistency. - Cleaned up SystemDetail.vue by removing unnecessary navigation actions for a more streamlined UI. - Enhanced conditional rendering in SystemDetailTabDependency to ensure form value checks are safe. - Replaced el-input with cl-edit-input in SystemDetailTabCustomize for improved input handling and added change event for saving.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
"github.com/crawlab-team/crawlab/core/models/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -16,7 +17,7 @@ func GetSetting(_ *gin.Context, params *GetSettingParams) (response *Response[mo
|
||||
// setting
|
||||
s, err := service.NewModelService[models.Setting]().GetOne(bson.M{"key": params.Key}, nil)
|
||||
if err != nil {
|
||||
if err == mongo.ErrNoDocuments {
|
||||
if errors.Is(err, mongo.ErrNoDocuments) {
|
||||
return GetDataResponse(models.Setting{})
|
||||
}
|
||||
return GetErrorResponse[models.Setting](err)
|
||||
|
||||
Reference in New Issue
Block a user