mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 13:44:05 -08:00
Add error propagation to web UI via special JSON error type.
This commit is contained in:
parent
49c87348b5
commit
1760d927c8
|
@ -132,10 +132,10 @@ func (matrix Matrix) ToString() string {
|
|||
func ErrorToJSON(err error) string {
|
||||
errorStruct := struct {
|
||||
Type string
|
||||
Error string
|
||||
Value string
|
||||
}{
|
||||
Type: "error",
|
||||
Error: err.Error(),
|
||||
Value: err.Error(),
|
||||
}
|
||||
|
||||
errorJSON, err := json.MarshalIndent(errorStruct, "", "\t")
|
||||
|
|
|
@ -84,6 +84,10 @@ function submitQuery() {
|
|||
dataType: "json",
|
||||
data: form.serialize(),
|
||||
success: function(json, textStatus) {
|
||||
if (json.Type == "error") {
|
||||
alert(json.Value);
|
||||
return;
|
||||
}
|
||||
data = transformData(json);
|
||||
if (data.length == 0) {
|
||||
alert("No datapoints found.");
|
||||
|
|
Loading…
Reference in a new issue