一段代码,分解下 THttpClient 抛出异常时的错误内容,以便去掉前面的 Error %errorcode% access accessing to %url%:,只取后面的实际错误消息内容。
function RemoveExceptionUrl(S: String): String; var p: PQCharW; begin if S = SNetHttpClientUnknownError then Result := '未知错误:执行请求时异常中止' else if StartWithW(PQCharW(S), 'Error ', false) then begin p := PQCharW(S); p := StrStrW(p, ': '); if Assigned(p) then begin Inc(p, 2); Result := p; end else Result := S; end else Result := S; end;