michael@0: /* michael@0: * Function to set error code only when meaningful error has not already michael@0: * been set. michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "prerror.h" michael@0: #include "secerr.h" michael@0: #include "sslerr.h" michael@0: #include "seccomon.h" michael@0: michael@0: /* look at the current value of PR_GetError, and evaluate it to see michael@0: * if it is meaningful or meaningless (out of context). michael@0: * If it is meaningless, replace it with the hiLevelError. michael@0: * Returns the chosen error value. michael@0: */ michael@0: int michael@0: ssl_MapLowLevelError(int hiLevelError) michael@0: { michael@0: int oldErr = PORT_GetError(); michael@0: michael@0: switch (oldErr) { michael@0: michael@0: case 0: michael@0: case PR_IO_ERROR: michael@0: case SEC_ERROR_IO: michael@0: case SEC_ERROR_BAD_DATA: michael@0: case SEC_ERROR_LIBRARY_FAILURE: michael@0: case SEC_ERROR_EXTENSION_NOT_FOUND: michael@0: case SSL_ERROR_BAD_CLIENT: michael@0: case SSL_ERROR_BAD_SERVER: michael@0: case SSL_ERROR_SESSION_NOT_FOUND: michael@0: PORT_SetError(hiLevelError); michael@0: return hiLevelError; michael@0: michael@0: default: /* leave the majority of error codes alone. */ michael@0: return oldErr; michael@0: } michael@0: }