com.amazonaws.services.cloudfront.model

## Class CustomErrorResponse

- java.lang.Object
- - com.amazonaws.services.cloudfront.model.CustomErrorResponse

All Implemented Interfaces:
  Serializable, Cloneable

    public class CustomErrorResponse
    extends Object
    implements Serializable, Cloneable

A complex type that controls:

- Whether CloudFront replaces HTTP status codes in the 4xx and 5xx range with custom error messages before returning the response to the viewer.

- How long CloudFront caches HTTP status codes in the 4xx and 5xx range.

For more information about custom error pages, see Customizing Error Responses in the Amazon CloudFront Developer Guide.

See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`CustomErrorResponse()`

### Method Summary

All Methods Instance Methods Concrete Methods
`CustomErrorResponse` `clone()`
`boolean` `equals(Object obj)`
`Long` `getErrorCachingMinTTL()` The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in `ErrorCode`.
`Integer` `getErrorCode()` The HTTP status code for which you want to specify a custom error page and/or a caching duration.
`String` `getResponseCode()` The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.
`String` `getResponsePagePath()` The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by `ErrorCode`, for example, `/4xx-errors/403-forbidden.html`.
`int` `hashCode()`
`void` `setErrorCachingMinTTL(Long errorCachingMinTTL)` The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in `ErrorCode`.
`void` `setErrorCode(Integer errorCode)` The HTTP status code for which you want to specify a custom error page and/or a caching duration.
`void` `setResponseCode(String responseCode)` The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.
`void` `setResponsePagePath(String responsePagePath)` The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by `ErrorCode`, for example, `/4xx-errors/403-forbidden.html`.
`String` `toString()` Returns a string representation of this object; useful for testing and debugging.
`CustomErrorResponse` `withErrorCachingMinTTL(Long errorCachingMinTTL)` The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in `ErrorCode`.
`CustomErrorResponse` `withErrorCode(Integer errorCode)` The HTTP status code for which you want to specify a custom error page and/or a caching duration.
`CustomErrorResponse` `withResponseCode(String responseCode)` The HTTP status code that you want CloudFront to return to the viewer along with the custom error page.
`CustomErrorResponse` `withResponsePagePath(String responsePagePath)` The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by `ErrorCode`, for example, `/4xx-errors/403-forbidden.html`.

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### CustomErrorResponse

    public CustomErrorResponse()

### Method Detail

#### setErrorCode

    public void setErrorCode(Integer errorCode)

The HTTP status code for which you want to specify a custom error page and/or a caching duration.

Parameters:
  `errorCode` - The HTTP status code for which you want to specify a custom error page and/or a caching duration.

#### getErrorCode

    public Integer getErrorCode()

The HTTP status code for which you want to specify a custom error page and/or a caching duration.

Returns:
  The HTTP status code for which you want to specify a custom error page and/or a caching duration.

#### withErrorCode

    public CustomErrorResponse withErrorCode(Integer errorCode)

The HTTP status code for which you want to specify a custom error page and/or a caching duration.

Parameters:
  `errorCode` - The HTTP status code for which you want to specify a custom error page and/or a caching duration.
Returns:
  Returns a reference to this object so that method calls can be chained together.

#### setResponsePagePath

    public void setResponsePagePath(String responsePagePath)

The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by `ErrorCode`, for example, `/4xx-errors/403-forbidden.html`. If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true:

- The value of `PathPattern` matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named `/4xx-errors`. Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example, `/4xx-errors/*`.

- The value of `TargetOriginId` specifies the value of the `ID` element for the origin that contains your custom error pages.

If you specify a value for `ResponsePagePath`, you must also specify a value for `ResponseCode`. If you don't want to specify a value, include an empty element, `<ResponsePagePath>`, in the XML document.

We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable.

Parameters:
  `responsePagePath` - The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by `ErrorCode`, for example, `/4xx-errors/403-forbidden.html`. If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true:

  - The value of `PathPattern` matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named `/4xx-errors`. Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example, `/4xx-errors/*`.

  - The value of `TargetOriginId` specifies the value of the `ID` element for the origin that contains your custom error pages.

  If you specify a value for `ResponsePagePath`, you must also specify a value for `ResponseCode`. If you don't want to specify a value, include an empty element, `<ResponsePagePath>`, in the XML document.

  We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable.

#### getResponsePagePath

    public String getResponsePagePath()

The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by `ErrorCode`, for example, `/4xx-errors/403-forbidden.html`. If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true:

- The value of `PathPattern` matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named `/4xx-errors`. Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example, `/4xx-errors/*`.

- The value of `TargetOriginId` specifies the value of the `ID` element for the origin that contains your custom error pages.

If you specify a value for `ResponsePagePath`, you must also specify a value for `ResponseCode`. If you don't want to specify a value, include an empty element, `<ResponsePagePath>`, in the XML document.

We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable.

Returns:
  The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by `ErrorCode`, for example, `/4xx-errors/403-forbidden.html`. If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true:

  - The value of `PathPattern` matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named `/4xx-errors`. Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example, `/4xx-errors/*`.

  - The value of `TargetOriginId` specifies the value of the `ID` element for the origin that contains your custom error pages.

  If you specify a value for `ResponsePagePath`, you must also specify a value for `ResponseCode`. If you don't want to specify a value, include an empty element, `<ResponsePagePath>`, in the XML document.

  We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable.

#### withResponsePagePath

    public CustomErrorResponse withResponsePagePath(String responsePagePath)

The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by `ErrorCode`, for example, `/4xx-errors/403-forbidden.html`. If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true:

- The value of `PathPattern` matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named `/4xx-errors`. Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example, `/4xx-errors/*`.

- The value of `TargetOriginId` specifies the value of the `ID` element for the origin that contains your custom error pages.

If you specify a value for `ResponsePagePath`, you must also specify a value for `ResponseCode`. If you don't want to specify a value, include an empty element, `<ResponsePagePath>`, in the XML document.

We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable.

Parameters:
  `responsePagePath` - The path to the custom error page that you want CloudFront to return to a viewer when your origin returns the HTTP status code specified by `ErrorCode`, for example, `/4xx-errors/403-forbidden.html`. If you want to store your objects and your custom error pages in different locations, your distribution must include a cache behavior for which the following is true:

  - The value of `PathPattern` matches the path to your custom error messages. For example, suppose you saved custom error pages for 4xx errors in an Amazon S3 bucket in a directory named `/4xx-errors`. Your distribution must include a cache behavior for which the path pattern routes requests for your custom error pages to that location, for example, `/4xx-errors/*`.

  - The value of `TargetOriginId` specifies the value of the `ID` element for the origin that contains your custom error pages.

  If you specify a value for `ResponsePagePath`, you must also specify a value for `ResponseCode`. If you don't want to specify a value, include an empty element, `<ResponsePagePath>`, in the XML document.

  We recommend that you store custom error pages in an Amazon S3 bucket. If you store custom error pages on an HTTP server and the server starts to return 5xx errors, CloudFront can't get the files that you want to return to viewers because the origin server is unavailable.

Returns:
  Returns a reference to this object so that method calls can be chained together.

#### setResponseCode

    public void setResponseCode(String responseCode)

The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:

- Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute `200`, the response typically won't be intercepted.

- If you don't care about distinguishing among different client errors or server errors, you can specify `400` or `500` as the `ResponseCode` for all 4xx or 5xx errors.

- You might want to return a `200` status code (OK) and static website so your customers don't know that your website is down.

If you specify a value for `ResponseCode`, you must also specify a value for `ResponsePagePath`. If you don't want to specify a value, include an empty element, `<ResponseCode>`, in the XML document.

Parameters:
  `responseCode` - The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:

  - Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute `200`, the response typically won't be intercepted.

  - If you don't care about distinguishing among different client errors or server errors, you can specify `400` or `500` as the `ResponseCode` for all 4xx or 5xx errors.

  - You might want to return a `200` status code (OK) and static website so your customers don't know that your website is down.

  If you specify a value for `ResponseCode`, you must also specify a value for `ResponsePagePath`. If you don't want to specify a value, include an empty element, `<ResponseCode>`, in the XML document.

#### getResponseCode

    public String getResponseCode()

The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:

- Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute `200`, the response typically won't be intercepted.

- If you don't care about distinguishing among different client errors or server errors, you can specify `400` or `500` as the `ResponseCode` for all 4xx or 5xx errors.

- You might want to return a `200` status code (OK) and static website so your customers don't know that your website is down.

If you specify a value for `ResponseCode`, you must also specify a value for `ResponsePagePath`. If you don't want to specify a value, include an empty element, `<ResponseCode>`, in the XML document.

Returns:
  The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:

  - Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute `200`, the response typically won't be intercepted.

  - If you don't care about distinguishing among different client errors or server errors, you can specify `400` or `500` as the `ResponseCode` for all 4xx or 5xx errors.

  - You might want to return a `200` status code (OK) and static website so your customers don't know that your website is down.

  If you specify a value for `ResponseCode`, you must also specify a value for `ResponsePagePath`. If you don't want to specify a value, include an empty element, `<ResponseCode>`, in the XML document.

#### withResponseCode

    public CustomErrorResponse withResponseCode(String responseCode)

The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:

- Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute `200`, the response typically won't be intercepted.

- If you don't care about distinguishing among different client errors or server errors, you can specify `400` or `500` as the `ResponseCode` for all 4xx or 5xx errors.

- You might want to return a `200` status code (OK) and static website so your customers don't know that your website is down.

If you specify a value for `ResponseCode`, you must also specify a value for `ResponsePagePath`. If you don't want to specify a value, include an empty element, `<ResponseCode>`, in the XML document.

Parameters:
  `responseCode` - The HTTP status code that you want CloudFront to return to the viewer along with the custom error page. There are a variety of reasons that you might want CloudFront to return a status code different from the status code that your origin returned to CloudFront, for example:

  - Some Internet devices (some firewalls and corporate proxies, for example) intercept HTTP 4xx and 5xx and prevent the response from being returned to the viewer. If you substitute `200`, the response typically won't be intercepted.

  - If you don't care about distinguishing among different client errors or server errors, you can specify `400` or `500` as the `ResponseCode` for all 4xx or 5xx errors.

  - You might want to return a `200` status code (OK) and static website so your customers don't know that your website is down.

  If you specify a value for `ResponseCode`, you must also specify a value for `ResponsePagePath`. If you don't want to specify a value, include an empty element, `<ResponseCode>`, in the XML document.

Returns:
  Returns a reference to this object so that method calls can be chained together.

#### setErrorCachingMinTTL

    public void setErrorCachingMinTTL(Long errorCachingMinTTL)

The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in `ErrorCode`. When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available.

If you don't want to specify a value, include an empty element, `<ErrorCachingMinTTL>`, in the XML document.

For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide.

Parameters:
  `errorCachingMinTTL` - The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in `ErrorCode`. When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available.

  If you don't want to specify a value, include an empty element, `<ErrorCachingMinTTL>`, in the XML document.

  For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide.

#### getErrorCachingMinTTL

    public Long getErrorCachingMinTTL()

The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in `ErrorCode`. When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available.

If you don't want to specify a value, include an empty element, `<ErrorCachingMinTTL>`, in the XML document.

For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide.

Returns:
  The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in `ErrorCode`. When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available.

  If you don't want to specify a value, include an empty element, `<ErrorCachingMinTTL>`, in the XML document.

  For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide.

#### withErrorCachingMinTTL

    public CustomErrorResponse withErrorCachingMinTTL(Long errorCachingMinTTL)

The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in `ErrorCode`. When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available.

If you don't want to specify a value, include an empty element, `<ErrorCachingMinTTL>`, in the XML document.

For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide.

Parameters:
  `errorCachingMinTTL` - The minimum amount of time, in seconds, that you want CloudFront to cache the HTTP status code specified in `ErrorCode`. When this time period has elapsed, CloudFront queries your origin to see whether the problem that caused the error has been resolved and the requested object is now available.

  If you don't want to specify a value, include an empty element, `<ErrorCachingMinTTL>`, in the XML document.

  For more information, see Customizing Error Responses in the Amazon CloudFront Developer Guide.

Returns:
  Returns a reference to this object so that method calls can be chained together.

#### toString

    public String toString()

Returns a string representation of this object; useful for testing and debugging.

Overrides:
  `toString` in class `Object`
Returns:
  A string representation of this object.
See Also:
  `Object.toString()`

#### equals

    public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### clone

    public CustomErrorResponse clone()

Overrides:
  `clone` in class `Object`