activities
latest
false
Importante :
A tradução automática foi aplicada parcialmente neste conteúdo. A localização de um conteúdo recém-publicado pode levar de 1 a 2 semanas para ficar disponível.
UiPath logo, featuring letters U and I in white

Atividades do fluxo de trabalho

Última atualização 19 de fev de 2026

Try Catch

System.Activities.Statements.TryCatch

Description

Captura um tipo de exceção especificado em uma sequência ou atividade e exibe uma notificação de erro ou a descarta e continua a execução.

Não há limite para quantas Catches você pode usar em uma atividade Try Catch . Esta atividade exige que pelo menos uma captura seja adicionada.

Compatibilidade do projeto

Windows - Legada | Windows | Multiplataforma

Configuração

O corpo da atividade contém três campos:

  • Try - The activity performed which has a chance of throwing an error.

  • Catches - The activity or set of activities to be performed when an error occurs.

    • Exceção - O tipo de exceção a ser procurado. Você pode adicionar várias exceções.
  • Finally - The activity or set of activities to be performed after the Try and Catches blocks are executed. This section is executed only when no exceptions are thrown or when an error occurs and is caught in the Catches section.

    docs image

Observação:
  • Se uma atividade estiver incluída na seção Tentar , e o valor da propriedade ContinuarComErro for True, nenhum erro será capturado quando o projeto for executado.
  • The Try Catch activity does not catch fatal exceptions such as:
    • FatalException
    • OutOfMemoryException
    • ThreadAbortException
    • FatalInternalException

Propriedades

Comum
  • DisplayName - O nome de exibição da atividade.
Diversos
  • Privado - Se selecionado, os valores de variáveis e argumentos não são mais registrados no nível Verbose.
    Observação:

    Pressing “Ctrl + T” places the selected activity inside the Try section of a Try Catch activity.

Exemplo de uso da atividade Try Catch

To better understand the importance of the Try Catch activity, we created an automation that gathers multiple names from a random name generator website and writes them in an Excel spreadsheet.

Observação:

Devido a uma limitação técnica, a Origem da exceção relatada em um cenário de Try-Catch pode ser diferente se a exceção ocorrer dentro de um fluxo de trabalho invocado.

A Build Data Table activity is used to create a table in which to store the gathered names. Another workflow is invoked to read the web data. Finally, an Excel application scope activity is used to write the gathered information in the Excel file.

First of all, let’s run the automation to check for any errors. Notice that a Workflow Exception window is displayed. The Exception Type field tells us what the problem is. This is used in the Catches section of a Try Catch as the exception type to look for during the workflow execution.

docs image

As you can see in the screenshot above, when running the example workflow, there seems to be a problem with the Attach Browser container selector. The issue is that the selector fails to identify the browser window with the “Generate a Random Name - Fake Name Generator” name.

Para capturar essa exceção, precisamos fazer o seguinte:

  1. Drag the Try Catch activity from the Activities panel above the Invoke workflow activity.

  2. Place the Invoke workflow activity in the Try section of the Try Catch activity. This watches the Invoke workflow activity in case it throws an error.

    docs image

  3. Na seção Catches , selecione a exceção UiPath.Core.SelectorNotFoundException no menu suspenso. Se não estiver lá, você pode encontrá-lo na janela Procurar e Selecionar um Tipo .Net .

    docs image

  4. Optionally, you can add a Message Box activity in the Catches section. You can fill in the Content field with an informative message between quotes, in our case “Internet Explorer was closed. It will now open to continue the workflow execution”. This means that whenever the exception is caught, this message box is displayed, to inform the user that the browser is about to open so that the workflow is successfully executed.

    docs image

  5. Arraste a atividade Element Exists na seção Finalmente . Isso é usado para verificar se o Internet Explorer está aberto na página de interesse, https://www.fakenamegenerator.com.

  6. Abra o Internet Explorer e acesse a página mencionada anteriormente.

  7. Use the Indicate on screen functionality to select the Internet Explorer window.

  8. Select the Element Exists activity and edit its selector so that it looks like this <wnd app='iexplore.exe' title='Generate a Random Name - Fake Name Generator - Internet Explorer' />. This selector ensures that the Element Exists activity only looks for an active Internet Explorer window in which the aforementioned page is open.

  9. In the Output property, create a variable with a relevant name, such as browser. This is a boolean variable which helps you determine whether or not Internet Explorer is active on the indicated page.

  10. Add an If activity under the Element Exists activity. This is used to open Internet Explorer if it’s closed, and continue the workflow otherwise.

  11. In the Condition field, write browser=false. This condition is used to verify if the browser is opened or not, and perform other actions, based on its value.

  12. Drag an Open Browser activity in the Then section. If the Condition is met (the browser is closed), then the Open Browser activity is used to open it, without affecting the workflow.

  13. No campo URL , digite https://www.fakenamegenerator.com.

  14. Leave the Else section empty so that the workflow continues as expected if Internet Explorer is already opened on the indicated website.

    docs image

  15. Execute o fluxo de trabalho e observe um dos seguintes:

  • Se o Internet Explorer estiver fechado - O usuário é informado de que o Internet Explorer está prestes a abrir para que o fluxo de trabalho possa continuar. O navegador é aberto, todos os dados esperados são coletados e gravados no arquivo Excel.
  • Se o Internet Explorer estiver aberto - o fluxo de trabalho é executado conforme o esperado.

Esta página foi útil?

Obtenha a ajuda que você precisa
Aprendendo RPA - Cursos de automação
Fórum da comunidade da Uipath
Uipath Logo
Confiança e segurança
© 2005-2026 UiPath. Todos os direitos reservados.