Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * Function to set error code only when meaningful error has not already |
michael@0 | 3 | * been set. |
michael@0 | 4 | * |
michael@0 | 5 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 6 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 7 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 8 | |
michael@0 | 9 | #include "prerror.h" |
michael@0 | 10 | #include "secerr.h" |
michael@0 | 11 | #include "sslerr.h" |
michael@0 | 12 | #include "seccomon.h" |
michael@0 | 13 | |
michael@0 | 14 | /* look at the current value of PR_GetError, and evaluate it to see |
michael@0 | 15 | * if it is meaningful or meaningless (out of context). |
michael@0 | 16 | * If it is meaningless, replace it with the hiLevelError. |
michael@0 | 17 | * Returns the chosen error value. |
michael@0 | 18 | */ |
michael@0 | 19 | int |
michael@0 | 20 | ssl_MapLowLevelError(int hiLevelError) |
michael@0 | 21 | { |
michael@0 | 22 | int oldErr = PORT_GetError(); |
michael@0 | 23 | |
michael@0 | 24 | switch (oldErr) { |
michael@0 | 25 | |
michael@0 | 26 | case 0: |
michael@0 | 27 | case PR_IO_ERROR: |
michael@0 | 28 | case SEC_ERROR_IO: |
michael@0 | 29 | case SEC_ERROR_BAD_DATA: |
michael@0 | 30 | case SEC_ERROR_LIBRARY_FAILURE: |
michael@0 | 31 | case SEC_ERROR_EXTENSION_NOT_FOUND: |
michael@0 | 32 | case SSL_ERROR_BAD_CLIENT: |
michael@0 | 33 | case SSL_ERROR_BAD_SERVER: |
michael@0 | 34 | case SSL_ERROR_SESSION_NOT_FOUND: |
michael@0 | 35 | PORT_SetError(hiLevelError); |
michael@0 | 36 | return hiLevelError; |
michael@0 | 37 | |
michael@0 | 38 | default: /* leave the majority of error codes alone. */ |
michael@0 | 39 | return oldErr; |
michael@0 | 40 | } |
michael@0 | 41 | } |