Y-lib
Loadrunner libraries
y_vts.c
Go to the documentation of this file.
1 /*
2  * Ylib Loadrunner function library.
3  * Copyright (C) 2009-2010 Raymond de Jongh <ferretproof@gmail.com> | <rdjongh@ymor.nl>
4  * Copyright (C) 2010,2014 Floris Kraak <randakar@gmail.com> | <fkraak@ymor.nl>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
33 #ifndef _Y_VTS_FUNC_C_
34 #define _Y_VTS_FUNC_C_
36 
38 /* \brief Standardised error reporting for all VTS functions.
39 
40 \author Floris Kraak
41 */
42 void y_vts_report_error(char* message)
43 {
44  lr_error_message("****** VTS ERROR: %s", message);
45 }
46 
103 int y_vts_process_returncode(int returncode)
104 {
105  char* errortext;
106 
107  // Encode the above information in a simple lookup table.
108  switch(returncode)
109  {
110  case VTCERR_OK:
111  //errortext = "INFO: VTS command succeeded.";
112  //lr_log_message(errortext);
113  return returncode;
114  break; // <-- never reached, but kept for readability.
115 
116  case VTCERR_INVALID_CONNECTION_INFO:
117  errortext = "The corresponding handle does not exist or the connection information is corrupted. Disconnect and reconnect.";
118  break;
119 
120  case VTCERR_FAILED_TO_RESOLVE_ADDR:
121  errortext = "Failed to resolve server address.";
122  break;
123 
124  case VTCERR_FAILED_TO_CREATE_SOCKET:
125  errortext = "Failed to create socket.";
126  break;
127 
128  case VTCERR_FAILED_TO_CONNECT:
129  errortext = "Failed to connect. Check the server name, port number, network connectivity, and whether server is on line."; // LR 11.52 simply calls lr_abort() if this happens.
130  break;
131 
132  case VTCERR_INVALID_API_CALL:
133  errortext = "Failed to get the API entry.";
134  break;
135 
136  case VTCERR_INCOMPLETE_REQUEST:
137  errortext = "Communications packet from client is invalid.";
138  break;
139 
140  case VTCERR_FAILED_TO_RECV_RESPONSE:
141  errortext = "No response received from server.";
142  break;
143 
144  case VTCERR_INCOMPLETE_RESPONSE:
145  errortext = "Response from server is incomplete.";
146  break;
147 
148  case VTCERR_RESPONSE_ARGS_UNMATCH:
149  errortext = "Unexpected count of arguments in server response.";
150  break;
151 
152  case VTCERR_INVALID_ARGUMENT:
153  errortext = "Invalid argument.";
154  break;
155 
156  case VTCERR_HANDLE_NOT_EXIST:
157  errortext = "Connection handle does not exist.";
158  break;
159 
160  case VTCERR_INNER_JSON_CONVERT:
161  errortext = "Cannot parse server (JSON) response.";
162  break;
163 
164  case VTCERR_INNER_UTF8_CONVERT:
165  errortext = "Cannot convert between UTF8 and Locale.";
166  break;
167 
168  case VTCERR_COL_FORMAT_ERROR:
169  errortext = "Invalid or empty column name.";
170  break;
171 
172  case VTCERR_COL_VALUE_NO_MATCH:
173  errortext = "Column names list and messages list do not have the same number of values. Check delimiters.";
174  break;
175 
176  case VTCERR_EVAL_STRING:
177  errortext = "Error evaluating parameter value.";
178  break;
179 
180  case VTCERR_DATA_NOT_EXIST:
181  errortext = "There is no data at the specified column and row.";
182  break;
183 
184  // These operation base errors may not exist in LR 11.52. The documentation no longer mentions them.
185  case VTCERR_OPERATION_ERROR_BASE:
186  errortext = "Received error code VTCERR_OPERATION_ERROR_BASE.";
187  break;
188 
189  case VTCERR_SERVER_IS_BUSY:
190  errortext = "Server is busy. Go away.";
191  break;
192 
193  case VTCERR_CLIENT_REQUEST_ERROR:
194  errortext = "Client request error.";
195  break;
196 
197  default:
198  errortext = "Unknown VTC error code.";
199  break;
200  }
201 
202  // Report the error to the user. (The "All OK" case jumped out of this function earlier ..)
203  y_vts_report_error(errortext);
204  // At this point it might be an idea to call lr_abort() or lr_exit(LR_EXIT_VUSER, LR_FAIL)
205 
206  return returncode;
207 }
208 
209 // --------------------------------------------------------------------------------------------------
210 #endif // _Y_VTS_FUNC_C_
void y_vts_report_error(char *message)
Definition: y_vts.c:42
int y_vts_process_returncode(int returncode)
Error translation and reporting facility for VTS return codes. This will emit VTS errors using lr_err...
Definition: y_vts.c:103