File: example_test.go

package info (click to toggle)
golang-github-juju-errors 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 196 kB
  • sloc: makefile: 21
file content (23 lines) | stat: -rw-r--r-- 480 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright 2013, 2014 Canonical Ltd.
// Licensed under the LGPLv3, see LICENCE file for details.

package errors_test

import (
	"fmt"

	"github.com/juju/errors"
)

func ExampleTrace() {
	var err1 error = fmt.Errorf("something wicked this way comes")
	var err2 error = nil

	// Tracing a non nil error will return an error
	fmt.Println(errors.Trace(err1))
	// Tracing nil will return nil
	fmt.Println(errors.Trace(err2))

	// Output: something wicked this way comes
	// <nil>
}