[DOCS-12360] Include mention of exception-handling in mongo scripts Created: 14/Jan/19  Updated: 30/Oct/23

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Major - P3
Reporter: Kelsey Schubert Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-38993 `mongo --eval` exits with status 0 on... Closed
Participants:
Days since reply: 1 year, 14 weeks, 2 days ago
Epic Link: DOCSP-1769
Story Points: 1

 Description   

Description

I believe that we can extend the follow page to include mention of error handling in mongo shell scripts: https://docs.mongodb.com/manual/tutorial/write-scripts-for-the-mongo-shell/

Could we include mention of asserts, like assert.commandWorked()? And instruct folks on how to use them to ensure mongo shell returns with the expected status code?

Available assert commands can be found here: https://github.com/mongodb/mongo/blob/r4.0.5/src/mongo/shell/assert.js

Scope of changes

  • Investigate usage of assert commands in mongo shell
  • Create examples of using assert commands to support better error handling in shell scripts
  • Backport to 4.0/3.6

 



 Comments   
Comment by Education Bot [ 31/Oct/22 ]

Hello! This ticket has been closed due to inactivity. If you believe this ticket is still important, please reopen it and leave a comment to explain why. Thank you!

Comment by Ravind Kumar (Inactive) [ 15/Jan/19 ]

We can try, though any input from engineers who have some guidance on best practices would be very much appreciated.

Generated at Thu Feb 08 08:05:03 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.