Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
@qp-mongosh/errors
Advanced tools
@qp-mongosh/errors
Package for MongoDB Shell
const { MongoshUnimplementedError } = require('@qp-mongosh/errors');
function evaluate(input) {
if (input === 'some input') {
throw new MongoshUnimplementedError(`${input} is not implemented`);
}
}
// throws: MongoshUnimplemetedError: some input is not implemented
evaluate('some input')
The idea of error codes is to allow easy identification of specific errors and map them to a proper documentation.
Error codes consist of a scope and a numeric part. They follow the pattern /^([a-zA-Z0-9]+)-/
.
Example: code='ASYNC-01005'
produces scope='ASYNC'
.
To better group error codes by their meaning, we suggest the following numbering scheme:
10000 - 89999
range for error codes that can be solved immediately by the user.90000 - 99999
range for error codes that are caused by internal limitations or violated assumptions.To generate an overview of all errors inside all packages with their documentation, you can run:
npx ts-node scripts/extract-errors.ts <path to /packages>
This will generate an error-overview.md
file in the current directory.
Remembery you can also use the metadata
of an error to provide additional information.
This enum provides common error codes that can be used throughout all packages for errors that do not need individual tracking.
All errors inherit from the abstract MongoshBaseError
which in turn inherits from Error
.
All MongoshBaseError
s have the following properties:
name
: inherited from Error
. The name of the error, corresponding to the concrete class name.message
: inherited from Error
. Descriptive message of the error.code
: optional. A unique identification code given when constructing the error.scope
: optional. The scope is automatically extracted from a given code
.metadata
: optional. Additional metadata for further analysis of the error cause.This error is used to give user a warning about the current execution. args:
This error is used to API endpoints that are not yet implemented. args:
Used for errors in evaluation, specific to MongoDB Shell. Should not be used for JavaScript runtime errors.
args:
Used for rare cases when MongoDB Shell is not able to parse and evaluate the input. args:
e.message
will be appended with the following information:
This is an error inside mongosh. Please file a bug report for the MONGOSH project here: https://jira.mongodb.org/projects/MONGOSH/issues.
Note: The error code will automatically be set to CommonErrors.UnexpectedInternalError
.
This error is used for invalid MongoDB input. This should not be used for JavaScript syntax errors, but rather for those specific to MongoDB. args:
This error is used when using a method or property that has been deprecated and was therefore already removed. args:
Note: The error code will automatically be set to CommonErrors.Deprecated
.
This error is used when running a database command unexpectedly failed but can be tried using runCommand
to get more details.
This should only be used when the result of a command returns with {ok: 0}
.
args:
Note: The error code will automatically be set to CommonErrors.CommandFailed
.
npm install -S @qp-mongosh/errors
FAQs
MongoDB Shell Errors Package
The npm package @qp-mongosh/errors receives a total of 6 weekly downloads. As such, @qp-mongosh/errors popularity was classified as not popular.
We found that @qp-mongosh/errors demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.