1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/base/net_errors.h"
12 #include "base/logging.h"
13 #include "base/stringprintf.h"
17 Error
MapSystemError(int os_error
) {
19 DVLOG(2) << "Error " << os_error
;
21 // There are numerous posix error codes, but these are the ones we thus far
25 #if EWOULDBLOCK != EAGAIN
28 return ERR_IO_PENDING
;
30 return ERR_ACCESS_DENIED
;
32 return ERR_INTERNET_DISCONNECTED
;
36 case ENETRESET
: // Related to keep-alive.
38 return ERR_CONNECTION_RESET
;
40 return ERR_CONNECTION_ABORTED
;
42 return ERR_CONNECTION_REFUSED
;
47 return ERR_ADDRESS_UNREACHABLE
;
49 return ERR_ADDRESS_INVALID
;
51 return ERR_MSG_TOO_BIG
;
53 return ERR_SOCKET_NOT_CONNECTED
;
55 return ERR_INVALID_ARGUMENT
;
57 return ERR_ADDRESS_IN_USE
;
58 case E2BIG
: // Argument list too long.
59 return ERR_INVALID_ARGUMENT
;
60 case EBADF
: // Bad file descriptor.
61 return ERR_INVALID_HANDLE
;
62 case EBUSY
: // Device or resource busy.
63 return ERR_INSUFFICIENT_RESOURCES
;
64 case ECANCELED
: // Operation canceled.
66 case EDEADLK
: // Resource deadlock avoided.
67 return ERR_INSUFFICIENT_RESOURCES
;
68 case EDQUOT
: // Disk quota exceeded.
69 return ERR_FILE_NO_SPACE
;
70 case EEXIST
: // File exists.
71 return ERR_FILE_EXISTS
;
72 case EFAULT
: // Bad address.
73 return ERR_INVALID_ARGUMENT
;
74 case EFBIG
: // File too large.
75 return ERR_FILE_TOO_BIG
;
76 case EISDIR
: // Is a directory.
77 return ERR_FILE_NOT_FOUND
;
78 case ENAMETOOLONG
: // Filename too long.
79 return ERR_FILE_PATH_TOO_LONG
;
80 case ENFILE
: // Too many open files in system.
81 return ERR_INSUFFICIENT_RESOURCES
;
82 case ENOBUFS
: // No buffer space available.
83 return ERR_OUT_OF_MEMORY
;
84 case ENODEV
: // No such device.
85 return ERR_INVALID_ARGUMENT
;
86 case ENOENT
: // No such file or directory.
87 return ERR_FILE_NOT_FOUND
;
88 case ENOLCK
: // No locks available.
89 return ERR_INSUFFICIENT_RESOURCES
;
90 case ENOMEM
: // Not enough space.
91 return ERR_OUT_OF_MEMORY
;
92 case ENOSPC
: // No space left on device.
93 return ERR_FILE_NO_SPACE
;
94 case ENOSYS
: // Function not implemented.
95 return ERR_NOT_IMPLEMENTED
;
96 case ENOTDIR
: // Not a directory.
97 return ERR_FILE_NOT_FOUND
;
98 case ENOTSUP
: // Operation not supported.
99 return ERR_NOT_IMPLEMENTED
;
100 case EPERM
: // Operation not permitted.
101 return ERR_ACCESS_DENIED
;
102 case EROFS
: // Read-only file system.
103 return ERR_ACCESS_DENIED
;
104 case ETXTBSY
: // Text file busy.
105 return ERR_ACCESS_DENIED
;
106 case EUSERS
: // Too many users.
107 return ERR_INSUFFICIENT_RESOURCES
;
108 case EMFILE
: // Too many open files.
109 return ERR_INSUFFICIENT_RESOURCES
;
114 LOG(WARNING
) << "Unknown error " << os_error
115 << " mapped to net::ERR_FAILED";