How to use make-error - 6 common examples

To help you get started, we’ve selected a few make-error examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github convoyinc / apollo-cache-hermes / src / errors.ts View on Github external
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
github SwellRT / swellrt / pad / node_modules / typings / node_modules / typings-core / node_modules / make-error-cause / dist / index.js View on Github external
(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;
github fossasia / susper.com / node_modules / ts-node / dist / index.js View on Github external
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
github serviejs / popsicle / popsicle.js View on Github external
(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;
github bfwg / angular-spring-starter / frontend / node_modules / ts-node / dist / index.js View on Github external
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
github jusbrasil / node-finagle / src / circuit-breaker.js View on Github external
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) => {

make-error

Make your own error types!

ISC
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis

Popular make-error functions