andre@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public andre@0: * License, v. 2.0. If a copy of the MPL was not distributed with this andre@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ andre@0: andre@0: /* andre@0: ** File:plerror.c andre@0: ** Description: Simple routine to print translate the calling thread's andre@0: ** error numbers and print them to "syserr". andre@0: */ andre@0: andre@0: #include "plerror.h" andre@0: andre@0: #include "prprf.h" andre@0: #include "prerror.h" andre@0: andre@0: PR_IMPLEMENT(void) PL_FPrintError(PRFileDesc *fd, const char *msg) andre@0: { andre@0: PRErrorCode error = PR_GetError(); andre@0: PRInt32 oserror = PR_GetOSError(); andre@0: const char *name = PR_ErrorToName(error); andre@0: andre@0: if (NULL != msg) PR_fprintf(fd, "%s: ", msg); andre@0: if (NULL == name) andre@0: PR_fprintf( andre@0: fd, " (%d)OUT OF RANGE, oserror = %d\n", error, oserror); andre@0: else andre@0: PR_fprintf( andre@0: fd, "%s(%d), oserror = %d\n", andre@0: name, error, oserror); andre@0: } /* PL_FPrintError */ andre@0: andre@0: PR_IMPLEMENT(void) PL_PrintError(const char *msg) andre@0: { andre@0: static PRFileDesc *fd = NULL; andre@0: if (NULL == fd) fd = PR_GetSpecialFD(PR_StandardError); andre@0: PL_FPrintError(fd, msg); andre@0: } /* PL_PrintError */ andre@0: andre@0: /* plerror.c */