michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 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: /* michael@0: ** File:plerror.c michael@0: ** Description: Simple routine to print translate the calling thread's michael@0: ** error numbers and print them to "syserr". michael@0: */ michael@0: michael@0: #include "plerror.h" michael@0: michael@0: #include "prprf.h" michael@0: #include "prerror.h" michael@0: michael@0: PR_IMPLEMENT(void) PL_FPrintError(PRFileDesc *fd, const char *msg) michael@0: { michael@0: PRErrorCode error = PR_GetError(); michael@0: PRInt32 oserror = PR_GetOSError(); michael@0: const char *name = PR_ErrorToName(error); michael@0: michael@0: if (NULL != msg) PR_fprintf(fd, "%s: ", msg); michael@0: if (NULL == name) michael@0: PR_fprintf( michael@0: fd, " (%d)OUT OF RANGE, oserror = %d\n", error, oserror); michael@0: else michael@0: PR_fprintf( michael@0: fd, "%s(%d), oserror = %d\n", michael@0: name, error, oserror); michael@0: } /* PL_FPrintError */ michael@0: michael@0: PR_IMPLEMENT(void) PL_PrintError(const char *msg) michael@0: { michael@0: static PRFileDesc *fd = NULL; michael@0: if (NULL == fd) fd = PR_GetSpecialFD(PR_StandardError); michael@0: PL_FPrintError(fd, msg); michael@0: } /* PL_PrintError */ michael@0: michael@0: /* plerror.c */