-
Notifications
You must be signed in to change notification settings - Fork 29
/
errors.go
44 lines (36 loc) · 1.24 KB
/
errors.go
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
// +build windows
package taskmaster
import (
"errors"
"syscall"
ole "github.com/go-ole/go-ole"
)
var (
ErrTargetUnsupported = errors.New("error connecting to the Task Scheduler service: cannot connect to the XP or server 2003 computer")
ErrConnectionFailure = errors.New("error connecting to the Task Scheduler service: cannot connect to target computer")
ErrInvalidPath = errors.New(`path must start with root folder "\"`)
ErrNoActions = errors.New("definition must have at least one action")
ErrInvalidPrinciple = errors.New("both UserId and GroupId are defined for the principal; they are mutually exclusive")
ErrRunningTaskCompleted = errors.New("the running task completed while it was getting parsed")
)
func getTaskSchedulerError(err error) error {
errCode := getOLEErrorCode(err)
switch errCode {
case 50:
return ErrTargetUnsupported
case 0x80070032, 53:
return ErrConnectionFailure
default:
return syscall.Errno(errCode)
}
}
func getRunningTaskError(err error) error {
errCode := getOLEErrorCode(err)
if errCode == 0x8004130B {
return ErrRunningTaskCompleted
}
return syscall.Errno(errCode)
}
func getOLEErrorCode(err error) uint32 {
return err.(*ole.OleError).SubError().(ole.EXCEPINFO).SCODE()
}