blob: ad07f451c9c6ae7617fda8379a752d723b785d46 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Author: arnej
package util
import (
"fmt"
"github.com/vespa-engine/vespa/client/go/internal/admin/trace"
)
type JustExitError struct {
err error
msg string
}
func (j *JustExitError) String() string {
if j.err != nil {
if j.msg == "" {
return j.err.Error()
}
return fmt.Sprintf("%s: %s", j.msg, j.err.Error())
}
if j.msg == "" {
panic(j)
}
return j.msg
}
func (j *JustExitError) Error() string {
return j.String()
}
func JustExitMsg(message string) {
trace.Trace("just exit with message")
j := JustExitError{
err: nil,
msg: message,
}
panic(&j)
}
func JustExitWith(e error) {
trace.Trace("just exit with error")
j := JustExitError{
err: e,
msg: "",
}
panic(&j)
}
|