forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeterrorcategory.cpp
More file actions
66 lines (62 loc) · 1.57 KB
/
geterrorcategory.cpp
File metadata and controls
66 lines (62 loc) · 1.57 KB
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "geterrorcategory.h"
#include <assert.h>
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
// Copy of PowerShell ErrorCategory enum from ErrorPackage.cs
enum ErrorCategory {
NotSpecified = 0,
OpenError = 1,
CloseError = 2,
DeviceError = 3,
DeadlockDetected = 4,
InvalidArgument = 5,
InvalidData = 6,
InvalidOperation = 7,
InvalidResult = 8,
InvalidType = 9,
MetadataError = 10,
NotImplemented = 11,
NotInstalled = 12,
ObjectNotFound = 13,
OperationStopped = 14,
OperationTimeout = 15,
SyntaxError = 16,
ParserError = 17,
PermissionDenied = 18,
ResourceBusy = 19,
ResourceExists = 20,
ResourceUnavailable = 21,
ReadError = 22,
WriteError = 23,
FromStdErr = 24,
SecurityError = 25,
ProtocolError = 26,
ConnectionError = 27,
AuthenticationError = 28,
LimitsExceeded = 29,
QuotaExceeded = 30,
NotEnabled = 31,
};
//! @brief Maps Linux errno to PowerShell ErrorCategory
int32_t GetErrorCategory(int32_t errnum)
{
switch (errnum)
{
case EINVAL:
return InvalidArgument;
case ENOENT:
case ESRCH:
return ObjectNotFound;
case EINTR:
return OperationStopped;
case EACCES:
case EPERM:
return PermissionDenied;
default:
return NotSpecified;
}
}