diff --git a/agent/pkg/controllers/entries_controller.go b/agent/pkg/controllers/entries_controller.go index 8b900b23d..167904e48 100644 --- a/agent/pkg/controllers/entries_controller.go +++ b/agent/pkg/controllers/entries_controller.go @@ -25,7 +25,12 @@ func Error(c *gin.Context, err error) bool { if err != nil { logger.Log.Errorf("Error getting entry: %v", 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 false // no error, can continue @@ -39,7 +44,13 @@ func GetEntry(c *gin.Context) { return // exit } 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 } diff --git a/ui/src/components/TrafficPage.tsx b/ui/src/components/TrafficPage.tsx index 51a33d372..804eea59a 100644 --- a/ui/src/components/TrafficPage.tsx +++ b/ui/src/components/TrafficPage.tsx @@ -189,6 +189,16 @@ export const TrafficPage: React.FC = ({setAnalyzeStatus, onTLS const entryData = await api.getEntry(focusedEntryId); setSelectedEntryData(entryData); } 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); } })()