mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-09 04:19:22 +00:00
Return 404
instead of 500
if the entry could not be found and display a toast message (#464)
This commit is contained in:
parent
1c75ce314b
commit
7f265dc4c5
@ -25,7 +25,12 @@ func Error(c *gin.Context, err error) bool {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Log.Errorf("Error getting entry: %v", err)
|
logger.Log.Errorf("Error getting entry: %v", err)
|
||||||
c.Error(err)
|
c.Error(err)
|
||||||
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"error": true, "msg": err.Error()})
|
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{
|
||||||
|
"error": true,
|
||||||
|
"type": "error",
|
||||||
|
"autoClose": "5000",
|
||||||
|
"msg": err.Error(),
|
||||||
|
})
|
||||||
return true // signal that there was an error and the caller should return
|
return true // signal that there was an error and the caller should return
|
||||||
}
|
}
|
||||||
return false // no error, can continue
|
return false // no error, can continue
|
||||||
@ -39,7 +44,13 @@ func GetEntry(c *gin.Context) {
|
|||||||
return // exit
|
return // exit
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(bytes, &entry)
|
err = json.Unmarshal(bytes, &entry)
|
||||||
if Error(c, err) {
|
if err != nil {
|
||||||
|
c.JSON(http.StatusNotFound, gin.H{
|
||||||
|
"error": true,
|
||||||
|
"type": "error",
|
||||||
|
"autoClose": "5000",
|
||||||
|
"msg": string(bytes),
|
||||||
|
})
|
||||||
return // exit
|
return // exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,6 +189,16 @@ export const TrafficPage: React.FC<TrafficPageProps> = ({setAnalyzeStatus, onTLS
|
|||||||
const entryData = await api.getEntry(focusedEntryId);
|
const entryData = await api.getEntry(focusedEntryId);
|
||||||
setSelectedEntryData(entryData);
|
setSelectedEntryData(entryData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
toast[error.response.data.type](`Entry[${focusedEntryId}]: ${error.response.data.msg}`, {
|
||||||
|
position: "bottom-right",
|
||||||
|
theme: "colored",
|
||||||
|
autoClose: error.response.data.autoClose,
|
||||||
|
hideProgressBar: false,
|
||||||
|
closeOnClick: true,
|
||||||
|
pauseOnHover: true,
|
||||||
|
draggable: true,
|
||||||
|
progress: undefined,
|
||||||
|
});
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
|
Loading…
Reference in New Issue
Block a user