fault icon indicating copy to clipboard operation
fault copied to clipboard

Add snippets

Open Southclaws opened this issue 2 years ago • 4 comments

Once API is v1, provide some snippets since I write errctx wrapping constantly:

{
  "if err != nil": {
    "prefix": "iferr",
    "body": [
      "if err != nil {",
      "\treturn nil, fault.Wrap(err, fctx.With(ctx))",
      "}"
    ],
    "description": "Snippet for if err != nil"
  }
}

Southclaws avatar Oct 19 '22 13:10 Southclaws

Yonk, I'll be taking that from you :P

Probably make a note that, that snippet only works in vscode?

ADRFranklin avatar Oct 31 '22 16:10 ADRFranklin

This is outdated now, errctx doesn't exist!

Southclaws avatar Oct 31 '22 18:10 Southclaws

Updated!

Southclaws avatar Oct 31 '22 19:10 Southclaws

Also, keep in mind if you're always using a specific set of decorators, you can easily build a helper:

func WrapWithDefaults(err error, ctx context.Context, message string) error {
  return fault.Wrap(err, fctx.With(ctx), fmsg.With(message))
}

Southclaws avatar Oct 31 '22 19:10 Southclaws