From cb442358beaf4e7bf4a430632cb3c5dc6f3e831d Mon Sep 17 00:00:00 2001 From: Fatih Arslan Date: Tue, 5 Jul 2016 01:52:27 +0300 Subject: [PATCH] snippets: add errp for error panic --- gosnippets/UltiSnips/go.snippets | 20 +++++++++++++++----- gosnippets/snippets/go.snip | 8 ++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/gosnippets/UltiSnips/go.snippets b/gosnippets/UltiSnips/go.snippets index 905d1d4211..41c4428062 100644 --- a/gosnippets/UltiSnips/go.snippets +++ b/gosnippets/UltiSnips/go.snippets @@ -151,21 +151,31 @@ if err != nil { ${0} endsnippet -# error snippet -snippet errt "Error test fatal " !b +# error multiple return +snippet errn, "Error return with two return values" !b if err != nil { - t.Fatal(err) + return ${1:nil}, err } ${0} endsnippet -snippet errn, "Error return with two return values" !b +# error panic +snippet errp "Error panic !b if err != nil { - return ${1:nil}, err + panic(${1}) +} +${0} +endsnippet + +# error test +snippet errt "Error test fatal " !b +if err != nil { + t.Fatal(err) } ${0} endsnippet +# error handle snippet errh "Error handle and return" !b if err != nil { ${1} diff --git a/gosnippets/snippets/go.snip b/gosnippets/snippets/go.snip index c24d2750b9..413eb1e145 100644 --- a/gosnippets/snippets/go.snip +++ b/gosnippets/snippets/go.snip @@ -149,6 +149,14 @@ abbr if err != nil { return } } ${0} +# error snippet with panic +snippet errp +abbr if err != nil { ... } + if err != nil { + panic(${1}) + } + ${0} + # json snippet snippet json abbr \`json:key\`