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
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)- A2% (1)
- B7% (4)
- C90% (55)
- D2% (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
Community Discussion
No community discussion yet for this question.