Debian Codegraph @

_test/ret8.go

raw symbols SCIP
1 package main
2
3 import "fmt"
4
5 type CustomError string
6
7 func (s CustomError) Error() string {
8 return string(s)
9 }
10
11 func NewCustomError(errorText string) CustomError {
12 return CustomError(errorText)
13 }
14
15 func fail() (err error) {
16 return NewCustomError("Everything is going wrong!")
17 }
18
19 func main() {
20 fmt.Println(fail())
21 var myError error
22 myError = NewCustomError("ok")
23 fmt.Println(myError)
24 }
25
26 // Output:
27 // Everything is going wrong!
28 // ok