diff options
author | Yury Smolsky <yury@smolsky.by> | 2018-05-20 10:57:22 +0300 |
---|---|---|
committer | Andrew Bonventre <andybons@golang.org> | 2018-05-25 02:41:13 +0000 |
commit | a5b4c53f6e8bdcafa95a94671bf2d1203365858b (patch) | |
tree | 5aef0f70620a3e2738ab2023925b976498ab7962 /godoc | |
parent | 1937f90a1bb43667aff4059b1bab13eb15121e8e (diff) | |
download | golang-x-tools-a5b4c53f6e8bdcafa95a94671bf2d1203365858b.tar.gz |
playground.js: display vet errors when program has no output
When program has no output and vet errors are encountered,
initialize data.Events as an empty array.
Fixes golang/go#25455.
Change-Id: Icedd77685b784505da3bb6383629cdfa8b8b22e9
Reviewed-on: https://go-review.googlesource.com/113875
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Diffstat (limited to 'godoc')
-rw-r--r-- | godoc/static/playground.js | 5 | ||||
-rw-r--r-- | godoc/static/static.go | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/godoc/static/playground.js b/godoc/static/playground.js index aad459fa3..1b7be65ac 100644 --- a/godoc/static/playground.js +++ b/godoc/static/playground.js @@ -109,7 +109,10 @@ function HTTPTransport(enableVet) { dataType: "json", success: function(dataVet) { if (dataVet.Errors) { - // inject errors from the vet as the first event in the output + if (!data.Events) { + data.Events = []; + } + // inject errors from the vet as the first events in the output data.Events.unshift({Message: 'Go vet exited.\n\n', Kind: 'system', Delay: 0}); data.Events.unshift({Message: dataVet.Errors, Kind: 'stderr', Delay: 0}); } diff --git a/godoc/static/static.go b/godoc/static/static.go index 051176213..20edbe6c8 100644 --- a/godoc/static/static.go +++ b/godoc/static/static.go @@ -2398,7 +2398,10 @@ function HTTPTransport(enableVet) { dataType: "json", success: function(dataVet) { if (dataVet.Errors) { - // inject errors from the vet as the first event in the output + if (!data.Events) { + data.Events = []; + } + // inject errors from the vet as the first events in the output data.Events.unshift({Message: 'Go vet exited.\n\n', Kind: 'system', Delay: 0}); data.Events.unshift({Message: dataVet.Errors, Kind: 'stderr', Delay: 0}); } |