New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

elasticsearch-exceptions

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elasticsearch-exceptions - npm Package Compare versions

Comparing version 0.0.2 to 0.0.4

lib/exceptions/ElasticsearchExceptionFactory.js

16

lib/ElasticsearchExceptions.js

@@ -6,19 +6,15 @@ 'use strict';

var exceptions = require('./exceptions');
// create factory helper
module.exports = function createExceptionfromError(err) {
// @todo
};
['AliasMissing', 'IndexMissing'].forEach(function (moduleName) {
// append
var exception = require(getModuleFile(moduleName));
module.exports[moduleName] = exception;
exceptions.SUPPORTED.forEach(function (exception_name) {
module.exports[exception_name] = exceptions[exception_name];
// create "is{ExceptionName}" helper
module.exports['is' + moduleName] = createIsGetter(exception, moduleName);
module.exports['is' + exception_name] = createIsGetter(exceptions[exception_name]);
});
function getModuleFile(moduleName) {
return p.resolve(__dirname, './exceptions', moduleName + '.exception');
}
function createIsGetter(module) {

@@ -25,0 +21,0 @@ assert(_.isFunction(module.is)); // module should implement is(err) -> boolean

'use strict';
var assert = require('better-assert');
var ElasticSearchExceptions = require('./');
var Exceptions = require('./');
describe('ElasticSearchExceptions', function () {
describe('ElasticSearchExceptions.isIndexMissing(err)', function () {
var INDEX_MISSING_ESERR = new ElasticSearchExceptions.IndexMissing("IndexMissingException[[aliasbringr-20141211-20141212] missing");
var INDEX_MISSING_ERR = new Error('IndexMissingException[[aliasbringr-20141211-20141212] missing]]');
describe('Exceptions', function () {
describe('Exceptions.isAggregationExecutionException(err)', function () {
var INDEX_MISSING_ESERR = new Exceptions.AggregationExecutionException("AggregationExecutionException[[qsdoijqspodij-20141211-20141212] missing");
var INDEX_MISSING_ERR = new Error('AggregationExecutionException[[qsdoijqspodij-20141211-20141212] missing]]');
it('should return false if this is not an alias missing error', function () {
assert(ElasticSearchExceptions.isIndexMissing() === false);
assert(ElasticSearchExceptions.isIndexMissing({}) === false);
assert(ElasticSearchExceptions.isIndexMissing(new Error('plop')) === false);
assert(Exceptions.isAggregationExecutionException() === false);
assert(Exceptions.isAggregationExecutionException({}) === false);
assert(Exceptions.isAggregationExecutionException(new Error('plop')) === false);
});
it('should return true if this is an alias missing error', function () {
assert(ElasticSearchExceptions.isIndexMissing(INDEX_MISSING_ERR) === true);
assert(ElasticSearchExceptions.isIndexMissing(INDEX_MISSING_ESERR) === true);
assert(Exceptions.isAggregationExecutionException(INDEX_MISSING_ERR) === true);
assert(Exceptions.isAggregationExecutionException(INDEX_MISSING_ESERR) === true);
});
});
describe('ElasticSearchExceptions.isAliasMissing(err)', function () {
var ALIAS_MISSING_ERR = new Error('AliasMissingException[[aliasbringr-20141211-20141212] missing]]');
var ALIAS_MISSING_ESERR = new ElasticSearchExceptions.AliasMissing("AliasMissingException[[aliasbringr-20141211-20141212] missing]]");
describe('Exceptions.isAliasesMissingException(err)', function () {
var ALIAS_MISSING_ERR = new Error('AliasesMissingException[[qsdoijqspodij-20141211-20141212] missing]]');
var ALIAS_MISSING_ESERR = new Exceptions.AliasesMissingException("AliasesMissingException[[qsdoijqspodij-20141211-20141212] missing]]");
it('should return false if this is not an alias missing error', function () {
assert(ElasticSearchExceptions.isAliasMissing() === false);
assert(ElasticSearchExceptions.isAliasMissing({}) === false);
assert(ElasticSearchExceptions.isAliasMissing(new Error('plop')) === false);
assert(Exceptions.isAliasesMissingException() === false);
assert(Exceptions.isAliasesMissingException({}) === false);
assert(Exceptions.isAliasesMissingException(new Error('plop')) === false);
});
it('should return true if this is an alias missing error', function () {
assert(ElasticSearchExceptions.isAliasMissing(ALIAS_MISSING_ERR) === true);
assert(ElasticSearchExceptions.isAliasMissing(ALIAS_MISSING_ESERR) === true);
assert(Exceptions.isAliasesMissingException(ALIAS_MISSING_ERR) === true);
assert(Exceptions.isAliasesMissingException(ALIAS_MISSING_ESERR) === true);
});
});
});
{
"name": "elasticsearch-exceptions",
"version": "0.0.2",
"version": "0.0.4",
"description": "Parse Elasticsearch exception responses and transform them into JavaScript Errors",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -12,10 +12,6 @@ Elasticsearch-exceptions

```
var ElasticsearchExceptions = require('elasticsearch-exceptions');
var EsEx = require('elasticsearch-exceptions');
someRequestToElasticSearchOrUsingANodeJSClient(function(err, ok){
if(ElasticsearchExceptions.isIndexMissing(err)){
// do something
}
if(ElasticsearchExceptions.isAliasMissing(err)){
if(EsEx.isAliasesMissingException(err)){
// do something else

@@ -30,1 +26,74 @@ }

});
```
# Supported exceptions (Elasticsearch v1.4.0)
```javascript
[
'AggregationExecutionException',
'AggregationInitializationException',
'AliasesMissingException',
'AlreadyExpiredException',
'BlobStoreException',
'CircuitBreakingException',
'ClusterBlockException',
'DelayRecoveryException',
'DiscoveryException',
'ElasticsearchException.WithRestHeaders',
'ElasticsearchGenerationException',
'ElasticsearchIllegalArgumentException',
'ElasticsearchIllegalStateException',
'ElasticsearchNullPointerException',
'ElasticsearchParseException',
'ElasticsearchTimeoutException',
'EsRejectedExecutionException',
'ExpressionScriptCompilationException',
'ExpressionScriptExecutionException',
'FacetPhaseExecutionException',
'FailedNodeException',
'FailedToResolveConfigException',
'GatewayException',
'GroovyScriptCompilationException',
'GroovyScriptExecutionException',
'HttpException',
'IgnoreRecoveryException',
'IndexException',
'IndexShardAlreadyExistsException',
'IndexTemplateAlreadyExistsException',
'IndexTemplateMissingException',
'IndexMissingException',
'IndexWarmerMissingException',
'InvalidIndexTemplateException',
'Lucene.EarlyTerminationException',
'MapperException',
'MasterNotDiscoveredException',
'NodeClosedException',
'NoNodeAvailableException',
'PercolateException',
'PrimaryMissingActionException',
'ProcessClusterEventTimeoutException',
'RecoveryFailedException',
'RepositoryException',
'RiverException',
'RoutingException',
'RoutingMissingException',
'ScriptException',
'SearchContextMissingException',
'SearchException',
'SearchPhaseExecutionException',
'SearchSourceBuilderException',
'SettingsException',
'SnapshotException',
'SuggestBuilderException',
'TimestampParsingException',
'TranslogCorruptedException',
'TransportException',
'UnavailableShardsException',
'UncategorizedExecutionException'
]
```
# Todo
- transform elasticsearch client errors to elasticsearch-exceptions
- parse exception body
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc