Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as makeError from 'make-error';
import { PathPart } from './primitive';
import { NodeId } from './schema';
/**
* Base error class for all errors emitted by the cache.
*
* Note that we rely on make-error so that we can safely extend the built in
* Error in a cross-platform manner.
*/
export class CacheError extends makeError.BaseError {}
/**
* An error with a query - generally occurs when parsing an error.
*/
export class QueryError extends CacheError {
constructor(
message: string,
// The path within the query where the error occurred.
public readonly path: string[],
) {
super(`${message} at ${prettyPath(path)}`);
}
}
/**
* An error with a read query - generally occurs when data in cache is partial
(function (makeErrorCause) {
var BaseError = (function (_super) {
__extends(BaseError, _super);
function BaseError(message, cause) {
_super.call(this, message);
this.cause = cause;
}
BaseError.prototype.toString = function () {
return _super.prototype.toString.call(this) + (this.cause ? "\nCaused by: " + this.cause.toString() : '');
};
return BaseError;
}(makeError.BaseError));
makeErrorCause.BaseError = BaseError;
})(makeErrorCause || (makeErrorCause = {}));
module.exports = makeErrorCause;
var message = path + " (" + (line + 1 + lineOffset) + "," + (character + 1) + "): " + messageText + " (" + diagnostic.code + ")";
return { message: message, code: diagnostic.code };
}
return { message: messageText + " (" + diagnostic.code + ")", code: diagnostic.code };
}
exports.formatDiagnostic = formatDiagnostic;
var TSError = (function (_super) {
__extends(TSError, _super);
function TSError(diagnostics) {
var _this = _super.call(this, "\u2A2F Unable to compile TypeScript\n" + diagnostics.map(function (x) { return x.message; }).join('\n')) || this;
_this.diagnostics = diagnostics;
_this.name = 'TSError';
return _this;
}
return TSError;
}(make_error_1.BaseError));
exports.TSError = TSError;
//# sourceMappingURL=index.js.map
(function (makeErrorCause) {
var BaseError = (function (_super) {
__extends(BaseError, _super);
function BaseError(message, cause) {
_super.call(this, message);
this.cause = cause;
}
BaseError.prototype.toString = function () {
return _super.prototype.toString.call(this) + (this.cause ? "\nCaused by: " + this.cause.toString() : '');
};
return BaseError;
})(makeError.BaseError);
makeErrorCause.BaseError = BaseError;
})(makeErrorCause || (makeErrorCause = {}));
module.exports = makeErrorCause;
var message = path + " (" + (line + 1 + lineOffset) + "," + (character + 1) + "): " + messageText + " (" + diagnostic.code + ")";
return { message: message, code: diagnostic.code };
}
return { message: messageText + " (" + diagnostic.code + ")", code: diagnostic.code };
}
exports.formatDiagnostic = formatDiagnostic;
var TSError = (function (_super) {
__extends(TSError, _super);
function TSError(diagnostics) {
var _this = _super.call(this, "\u2A2F Unable to compile TypeScript\n" + diagnostics.map(function (x) { return x.message; }).join('\n')) || this;
_this.diagnostics = diagnostics;
_this.name = 'TSError';
return _this;
}
return TSError;
}(make_error_1.BaseError));
exports.TSError = TSError;
//# sourceMappingURL=index.js.map
import CircuitBreaker from 'circuit-breaker-js';
import makeError from 'make-error';
import type { Filter, Service } from './index';
type CircuitBreakerOptions = {
breaker?: Object,
isFailure?: (ex: Error) => boolean,
stats?: {
countCircuitOpen: (req: Req) => void,
countCircuitClose: (req: Req) => void,
},
};
export const CircuitBreakerOpen = makeError('CircuitBreakerOpen');
export default function circuitBreakerFilter(
options: CircuitBreakerOptions,
): Filter {
const {
isFailure = () => true,
breaker = new CircuitBreaker(options),
stats,
} = options;
return (service: Service) => (input: Req) => (
new Promise((resolve, reject) => {
const cmd = (success, failure) => {
const promise = service(input);
promise.then(resolve, reject);
promise.then(success, (ex) => {