| 1182 | |
| 1183 | |
| 1184 | void CommunicationManager::handleEDAMSystemException(EDAMSystemException e) { |
| 1185 | |
| 1186 | // Windows Check |
| 1187 | #ifndef _WIN32 |
| 1188 | void *array[30]; |
| 1189 | size_t size; |
| 1190 | // get void*'s for all entries on the stack |
| 1191 | size = backtrace(array, 30); |
| 1192 | |
| 1193 | // print out all the frames to stderr |
| 1194 | fprintf(stderr, "EDAM System Exception backtrace"); |
| 1195 | backtrace_symbols_fd(array, size, 2); |
| 1196 | #endif // End windows check |
| 1197 | |
| 1198 | if (e.message.isSet()) { |
| 1199 | QLOG_ERROR() << "EDAMSystemException:" << e.message << endl; |
| 1200 | } |
| 1201 | QLOG_ERROR() << "EDAMSystemException Error Code:" << e.errorCode << endl; |
| 1202 | if (e.rateLimitDuration.isSet()) { |
| 1203 | QLOG_ERROR() << "EDAMSystemException Rate Limit:" << e.rateLimitDuration << endl; |
| 1204 | } |
| 1205 | if (e.errorCode == EDAMErrorCode::RATE_LIMIT_REACHED) { |
| 1206 | int duration = e.rateLimitDuration/60+1; |
| 1207 | error.type = CommunicationError::RateLimitExceeded; |
| 1208 | if (duration > 1) |
| 1209 | error.message = tr("API rate limit exceeded. Please try again in ") +QString::number(duration)+ tr(" minutes."); |
| 1210 | else |
| 1211 | error.message = tr("API rate limit exceeded. Please try again in ") +QString::number(duration)+ tr(" minute."); |
| 1212 | return; |
| 1213 | } |
| 1214 | if (e.message.isSet()) |
| 1215 | error.message = tr("EDAMSystemException ") + e.message + errorWhat(e.what()); |
| 1216 | else |
| 1217 | error.message = tr("EDAMSystemException: Unknown error") + errorWhat(e.what()); |
| 1218 | error.type = CommunicationError::EDAMSystemException; |
| 1219 | error.code = e.errorCode; |
| 1220 | } |
| 1221 | |
| 1222 | |
| 1223 | |