MCPcopy Create free account
hub / github.com/mhammond/pywin32 / ExtensionError

Function ExtensionError

isapi/src/PythonEng.cpp:363–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361// general error handler
362
363void ExtensionError(CControlBlock *pcb, const char *errmsg)
364{
365 char *windows_error = ::GetLastError() ?
366 ::FormatSysError(::GetLastError()) : NULL;
367 { // temp scope to release python lock
368 CEnterLeavePython celp;
369 PySys_WriteStderr("Internal Extension Error: %s\n", errmsg);
370 if (windows_error)
371 PySys_WriteStderr("Last Windows error: %s\n", windows_error);
372 if (PyErr_Occurred()) {
373 PyErr_Print();
374 PyErr_Clear();
375 }
376 } // end temp scope
377 if (pcb) {
378 char *htmlStream = HTMLErrorResp(errmsg);
379
380 pcb->SetStatus(HSE_STATUS_ERROR);
381 pcb->SetLogMessage(errmsg);
382 HSE_SEND_HEADER_EX_INFO SendHeaderExInfo;
383 SendHeaderExInfo.pszStatus = "200 OK";
384 SendHeaderExInfo.cchStatus = strlen(SendHeaderExInfo.pszStatus);
385 SendHeaderExInfo.pszHeader = "Content-type: text/html\r\n\r\n";
386 SendHeaderExInfo.cchHeader = strlen(SendHeaderExInfo.pszHeader);
387 SendHeaderExInfo.fKeepConn = FALSE;
388 EXTENSION_CONTROL_BLOCK * ecb = pcb->GetECB();
389 ecb->ServerSupportFunction(ecb->ConnID, HSE_REQ_SEND_RESPONSE_HEADER_EX, &SendHeaderExInfo, NULL,NULL);
390 pcb->WriteStream(htmlStream, strlen(htmlStream));
391 if (windows_error) {
392 static char *chunk = "<br>Last Windows error:";
393 pcb->WriteStream(chunk, strlen(chunk));
394 pcb->WriteStream(windows_error, strlen(windows_error));
395 }
396 }
397 const char *inserts[] = {errmsg, windows_error ? windows_error : "n/a"};
398 WriteEventLogMessage(EVENTLOG_ERROR_TYPE, E_PYISAPI_EXTENSION_FAILED,
399 2, inserts);
400 if (windows_error)
401 free(windows_error);
402}
403
404void FilterError(CFilterContext *pfc, const char *errmsg)
405{

Callers 7

LoadHandlerMethod · 0.70
CheckCallbackMethod · 0.70
CallbackMethod · 0.70
GetExtensionVersionFunction · 0.70
HttpExtensionProcFunction · 0.70
TerminateExtensionFunction · 0.70
transmitFileCompletionFunction · 0.70

Calls 8

FormatSysErrorFunction · 0.85
HTMLErrorRespFunction · 0.85
WriteEventLogMessageFunction · 0.85
SetStatusMethod · 0.80
SetLogMessageMethod · 0.80
GetECBMethod · 0.80
ServerSupportFunctionMethod · 0.80
WriteStreamMethod · 0.80

Tested by

no test coverage detected