How to use the @azure/core-http.HttpPipelineLogLevel.ERROR function in @azure/core-http

To help you get started, we’ve selected a few @azure/core-http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-sdk-for-js / sdk / storage / storage-file / src / policies / LoggingPolicy.ts View on Github external
);
      this.log(
        HttpPipelineLogLevel.INFO,
        `  response headers: ${JSON.stringify(sanitizeHeaders(response.headers), null, 2)}`
      );

      return response;
    } catch (err) {
      if (err instanceof RestError && err.request) {
        this.log(
          HttpPipelineLogLevel.INFO,
          `  request headers: ${JSON.stringify(sanitizeHeaders(err.request.headers), null, 2)}`
        );
      }
      this.log(
        HttpPipelineLogLevel.ERROR,
        `Unexpected failure attempting to make request. Error message: ${err.message}`
      );
      throw err;
    }
  }
}
github Azure / azure-sdk-for-js / sdk / storage / storage-queue / src / policies / StorageRetryPolicy.ts View on Github external
let response: HttpOperationResponse | undefined;
    try {
      this.logf(
        HttpPipelineLogLevel.INFO,
        `RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? "Primary" : "Secondary"}`
      );
      response = await this._nextPolicy.sendRequest(newRequest);
      if (!this.shouldRetry(isPrimaryRetry, attempt, response)) {
        return response;
      }

      secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);
    } catch (err) {
      this.logf(
        HttpPipelineLogLevel.ERROR,
        `RetryPolicy: Caught error, message: ${err.message}, code: ${err.code}`
      );
      if (!this.shouldRetry(isPrimaryRetry, attempt, response, err)) {
        throw err;
      }
    }

    await this.delay(isPrimaryRetry, attempt, request.abortSignal);
    return await this.attemptSendRequest(request, secondaryHas404, ++attempt);
  }
github Azure / azure-sdk-for-js / sdk / storage / storage-file-share / src / policies / StorageRetryPolicy.ts View on Github external
let response: HttpOperationResponse | undefined;
    try {
      this.logf(
        HttpPipelineLogLevel.INFO,
        `RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? "Primary" : "Secondary"}`
      );
      response = await this._nextPolicy.sendRequest(newRequest);
      if (!this.shouldRetry(isPrimaryRetry, attempt, response)) {
        return response;
      }

      secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);
    } catch (err) {
      this.logf(
        HttpPipelineLogLevel.ERROR,
        `RetryPolicy: Caught error, message: ${err.message}, code: ${err.code}`
      );
      if (!this.shouldRetry(isPrimaryRetry, attempt, response, err)) {
        throw err;
      }
    }

    await this.delay(isPrimaryRetry, attempt, request.abortSignal);
    return await this.attemptSendRequest(request, secondaryHas404, ++attempt);
  }
github Azure / azure-sdk-for-js / sdk / storage / storage-file / src / policies / RetryPolicy.ts View on Github external
let response: HttpOperationResponse | undefined;
    try {
      this.logf(
        HttpPipelineLogLevel.INFO,
        `RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? "Primary" : "Secondary"}`
      );
      response = await this._nextPolicy.sendRequest(newRequest);
      if (!this.shouldRetry(isPrimaryRetry, attempt, response)) {
        return response;
      }

      secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);
    } catch (err) {
      this.logf(
        HttpPipelineLogLevel.ERROR,
        `RetryPolicy: Caught error, message: ${err.message}, code: ${err.code}`
      );
      if (!this.shouldRetry(isPrimaryRetry, attempt, response, err)) {
        throw err;
      }
    }

    await this.delay(isPrimaryRetry, attempt, request.abortSignal);
    return await this.attemptSendRequest(request, secondaryHas404, ++attempt);
  }
github Azure / azure-sdk-for-js / sdk / storage / storage-policies / StorageRetryPolicy.ts View on Github external
let response: HttpOperationResponse | undefined;
    try {
      this.logf(
        HttpPipelineLogLevel.INFO,
        `RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? "Primary" : "Secondary"}`
      );
      response = await this._nextPolicy.sendRequest(newRequest);
      if (!this.shouldRetry(isPrimaryRetry, attempt, response)) {
        return response;
      }

      secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);
    } catch (err) {
      this.logf(
        HttpPipelineLogLevel.ERROR,
        `RetryPolicy: Caught error, message: ${err.message}, code: ${err.code}`
      );
      if (!this.shouldRetry(isPrimaryRetry, attempt, response, err)) {
        throw err;
      }
    }

    await this.delay(isPrimaryRetry, attempt, request.abortSignal);
    return await this.attemptSendRequest(request, secondaryHas404, ++attempt);
  }
github Azure / azure-sdk-for-js / sdk / storage / storage-queue / src / policies / LoggingPolicy.ts View on Github external
if (
        (response.status >= 400 &&
          response.status <= 499 &&
          (response.status !== HTTPURLConnection.HTTP_NOT_FOUND &&
            response.status !== HTTPURLConnection.HTTP_CONFLICT &&
            response.status !== HTTPURLConnection.HTTP_PRECON_FAILED &&
            response.status !== HTTPURLConnection.HTTP_RANGE_NOT_SATISFIABLE)) ||
        (response.status >= 500 && response.status <= 509)
      ) {
        const errorString = `REQUEST ERROR: HTTP request failed with status code: ${
          response.status
        }. `;
        logMessage = errorString;

        currentLevel = HttpPipelineLogLevel.ERROR;
      }

      const messageInfo = `Request try:${this.tryCount}, status:${
        response.status
      } request duration:${requestCompletionTime} ms, operation duration:${operationDuration} ms\n`;
      this.log(currentLevel, logMessage + messageInfo);

      return response;
    } catch (err) {
      this.log(
        HttpPipelineLogLevel.ERROR,
        `Unexpected failure attempting to make request. Error message: ${err.message}`
      );
      throw err;
    }
  }