LibRan  0.1
Pseudo-random number distribution generator
LRerror.c
Go to the documentation of this file.
1 
53 /*
54  * Copyright 2019 R.K. Owen, Ph.D.
55  * License see lgpl.md (Gnu Lesser General Public License)
56  */
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 #include <stdio.h>
62 #include "libran.h"
63 
71 char *LRstrerror(int LRerrno) {
72  switch (LRerrno) {
73  case LRerr_OK:
74  return "LibRan - No Error";
75  case LRerr_Unspecified:
76  return "LibRan - Unspecified Error";
77  case LRerr_BadDataType:
78  return "LibRan - Bad Data Type given";
79  case LRerr_BadLRType:
80  return "LibRan - Bad Random Variate Type given";
82  return "LibRan - Required Auxiliary Object not found";
84  return "LibRan - Auxiliary Object requires normalization";
85  case LRerr_BadAuxSetup:
86  return "LibRan - Auxiliary Object incorrectly set-up";
87  case LRerr_BinGeneric:
88  return "LibRan - Binning Object Unspecified Error";
90  return "LibRan - Too Many Values given";
92  return "LibRan - Invalid Input Value Error";
93  case LRerr_InvalidRange:
94  return "LibRan - Invalid Range Value Error";
96  return "LibRan - Preconditions Not Performed";
98  return "LibRan - Suspicious Value - Normalization Error?";
99  case LRerr_AllocFail:
100  return "LibRan - Memory Allocation Error";
101  }
102  return "LibRan - Invalid errno";
103 }
104 
112 char *LRstrerrno(int LRerrno) {
113  switch (LRerrno) {
114  case LRerr_OK:
115  return "LRerr_OK";
116  case LRerr_Unspecified:
117  return "LRerr_Unspecified";
118  case LRerr_BadDataType:
119  return "LRerr_BadDataType";
120  case LRerr_BadLRType:
121  return "LRerr_BadLRType";
123  return "LRerr_NoAuxiliaryObject";
125  return "LRerr_NoAuxNormalizeDone";
126  case LRerr_BadAuxSetup:
127  return "LRerr_BadAuxSetup";
128  case LRerr_BinGeneric:
129  return "LRerr_BinGeneric";
130  case LRerr_TooManyValues:
131  return "LRerr_TooManyValues";
133  return "LRerr_InvalidInputValue";
134  case LRerr_InvalidRange:
135  return "LRerr_InvalidRange";
137  return "LRerr_UnmetPreconditions";
139  return "LRerr_SuspiciousValues";
140  case LRerr_AllocFail:
141  return "LRerr_AllocFail";
142  }
143  return "";
144 }
145 
157 void LRperror(char *str, int LRerrno) {
158  if (str) {
159  fprintf(stderr,"%s : %s\n", str, LRstrerror(LRerrno));
160  } else {
161  fprintf(stderr,"%s\n", LRstrerror(LRerrno));
162  }
163 }
164 
165 #ifdef __cplusplus
166 }
167 #endif
#define LRerr_SuspiciousValues
Definition: libran.h:44
#define LRerr_OK
Definition: libran.h:32
#define LRerr_BinGeneric
Definition: libran.h:39
#define LRerr_BadAuxSetup
Definition: libran.h:38
#define LRerr_TooManyValues
Definition: libran.h:40
char * LRstrerror(int LRerrno)
LRstrerror(int LRerrno) - return some explanatory text regarding the given LibRan errno...
Definition: LRerror.c:71
#define LRerr_UnmetPreconditions
Definition: libran.h:43
void LRperror(char *str, int LRerrno)
LRperror(char *str, int LRerrno) - print out explanatory error message to stderr. ...
Definition: LRerror.c:157
#define LRerr_InvalidRange
Definition: libran.h:42
#define LRerr_NoAuxNormalizeDone
Definition: libran.h:37
#define LRerr_BadDataType
Definition: libran.h:34
#define LRerr_AllocFail
Definition: libran.h:45
char * LRstrerrno(int LRerrno)
LRstrerrno(int LRerrno) - return the errno code string for the given LibRan errno.
Definition: LRerror.c:112
#define LRerr_BadLRType
Definition: libran.h:35
#define LRerr_NoAuxiliaryObject
Definition: libran.h:36
The LibRan common header file.
#define LRerr_Unspecified
Definition: libran.h:33
#define LRerr_InvalidInputValue
Definition: libran.h:41