|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* |
|
7 ** File:plerror.c |
|
8 ** Description: Simple routine to print translate the calling thread's |
|
9 ** error numbers and print them to "syserr". |
|
10 */ |
|
11 |
|
12 #include "plerror.h" |
|
13 |
|
14 #include "prprf.h" |
|
15 #include "prerror.h" |
|
16 |
|
17 PR_IMPLEMENT(void) PL_FPrintError(PRFileDesc *fd, const char *msg) |
|
18 { |
|
19 PRErrorCode error = PR_GetError(); |
|
20 PRInt32 oserror = PR_GetOSError(); |
|
21 const char *name = PR_ErrorToName(error); |
|
22 |
|
23 if (NULL != msg) PR_fprintf(fd, "%s: ", msg); |
|
24 if (NULL == name) |
|
25 PR_fprintf( |
|
26 fd, " (%d)OUT OF RANGE, oserror = %d\n", error, oserror); |
|
27 else |
|
28 PR_fprintf( |
|
29 fd, "%s(%d), oserror = %d\n", |
|
30 name, error, oserror); |
|
31 } /* PL_FPrintError */ |
|
32 |
|
33 PR_IMPLEMENT(void) PL_PrintError(const char *msg) |
|
34 { |
|
35 static PRFileDesc *fd = NULL; |
|
36 if (NULL == fd) fd = PR_GetSpecialFD(PR_StandardError); |
|
37 PL_FPrintError(fd, msg); |
|
38 } /* PL_PrintError */ |
|
39 |
|
40 /* plerror.c */ |