nerdexam
Microsoft

GH-200 · Question #67

You are a DevOps engineer working on custom Actions development. You need to handle the errors or exceptions as part of the JavaScript based action code. What should be added to the following code blo

The correct answer is C. core.setFailed(error.message);. Setting a failure exit code in a JavaScript action If you are creating a JavaScript action, you can use the actions toolkit @actions/core package to log a message and set a failure exit code. For example: } catch (error) { core.setFailed(error.message); https://docs.github.com/en

Author and Maintain Actions

Question

You are a DevOps engineer working on custom Actions development. You need to handle the errors or exceptions as part of the JavaScript based action code. What should be added to the following code block to handle errors? const core = require('@actions/core'); try { // action code } catch (error) { << insert snippet here >> }

Options

  • Acore.setException(error.message);
  • Baction.setError(error.message);
  • Ccore.setFailed(error.message);
  • Dcore.action.setException(error.message);

How the community answered

(61 responses)
  • A
    2% (1)
  • B
    7% (4)
  • C
    90% (55)
  • D
    2% (1)

Explanation

Setting a failure exit code in a JavaScript action If you are creating a JavaScript action, you can use the actions toolkit @actions/core package to log a message and set a failure exit code. For example: } catch (error) { core.setFailed(error.message); https://docs.github.com/en/actions/how-tos/create-and-publish-actions/set-exit-codes

Topics

#GitHub Actions#Custom Actions#Error Handling#JavaScript Actions API

Community Discussion

No community discussion yet for this question.

Full GH-200 Practice