---
schema_version: "1"
id: d37a7a8a37e1d7404c204743492f1fc447e86b932f4c6bd11f0f2f3c5d645111
title: RTRReportResult.MockException
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/retail_api/MockException_class.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/MockException_class.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 04c41b72632c957dd6dd69a14f2ca935aeb1f6d3fc29908392ee1941db80b56e
description: This class is used to create mock exceptions for the unit test execution.
---
# RTRReportResult.MockException

This class is used to create mock exceptions for the unit test execution.

The RTRReportResult.MockException class extends Exception.

The supported modifier is global.

## Namespace

cgcloud

## Supported Methods

<table class="featureTable sort_table" summary="">
          <caption><span class="tablecap">Table 1. RTRReportResult.MockException Supported Methods</span></caption>



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d34806e83">Method signature</th>

              <th class="featureTableHeader  " id="d34806e86">Description</th>

              <th class="featureTableHeader  " id="d34806e89">Version</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d34806e83" data-title="Method signature"><samp class="codeph nolang">RTRReportResult.MockException​(String
                  message)</samp></td>

              <td class="entry" headers="d34806e86" data-title="Description">The constructor for creating mock exceptions for the unit test execution.
                <p class="p"><span class="keyword parmname">message</span>: String. The message to return as part of the
                  exception.</p>
              </td>

              <td class="entry" headers="d34806e89" data-title="Version">60.0</td>

            </tr>

          </tbody>

        </table>

## Example Implementation

To unit test error handling scenarios, set up a mock exception to be thrown during execution.

 @IsTest
  public static void myTestMethod() {
    // Setup
    
    // Setup your required data for the test
    
    // Create a mock RTRReportResult
    cgcloud.RTRReportResult.MockException mockException = new cgcloud.RTRReportResult.MockException(
      'Sample Error'
    );
    
    // Set the mock in RTRReportResult.execute so the call to this method
    // returns our mock response
    cgcloud.RTRReportResult.setMock(new List<Object>{ mockException });
    
    // Test
    
    // Run your code to be tested. RTRReportResult.execute call will
    // throw a CGCloudException with the mock exception message
    
    // Assert
    
    // Assert your code is working as expected.
  }