aboutsummaryrefslogtreecommitdiffstats
path: root/error.go
blob: d90d1b8d1255858d8db67ec27d95445f496a4662 (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package browserenv

import "fmt"

const errorPrefix = "browserenv: "

// CopyError represents a failure to copy data.
type CopyError struct {
	err error
}

func (e *CopyError) Error() string {
	return fmt.Sprintf(errorPrefix+"can't copy from reader: %v", e.err)
}

func (e *CopyError) Unwrap() error { return e.err }

// ExecError results from executing an external command.
type ExecError struct {
	command string
	err     error
}

func (e *ExecError) Error() string {
	return fmt.Sprintf(
		errorPrefix+"failed to run BROWSER command %q: %v",
		e.command,
		e.err,
	)
}

func (e *ExecError) Unwrap() error { return e.err }

// ExecZeroError results from executing an external command that produces an
// error with an exit code of 0.
type ExecZeroError struct {
	command string
	err     error
}

func (e *ExecZeroError) Error() string {
	return fmt.Sprintf(
		errorPrefix+"error running command %q: %v",
		e.command,
		e.err,
	)
}

func (e *ExecZeroError) Unwrap() error { return e.err }

// PathResolutionError means the given path couldn't be resolved.
type PathResolutionError struct {
	path string
	err  error
}

func (e *PathResolutionError) Error() string {
	return fmt.Sprintf(
		errorPrefix+"can't resolve path for %q: %v",
		e.path,
		e.err,
	)
}

func (e *PathResolutionError) Unwrap() error { return e.err }

// TempFileError corresponds to an error while creating a temporary file.
type TempFileError struct {
	err error
}

func (e *TempFileError) Error() string {
	return fmt.Sprintf(errorPrefix+"can't create temporary file: %v", e.err)
}

func (e *TempFileError) Unwrap() error { return e.err }