// Generated by CoffeeScript 1.10.0

/* jshint node:true */


/* jshint -W097 */

(function() {
  'use strict';
  var FtpReconnectError,
    extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
    hasProp = {}.hasOwnProperty;

  FtpReconnectError = (function(superClass) {
    extend(FtpReconnectError, superClass);

    function FtpReconnectError(disconnectError, connectError, onCwd) {
      var connectErrorStack, disconnectErrorStack, mainMsg, prefix, suffix;
      if (disconnectError == null) {
        disconnectError = '';
      }
      if (connectError == null) {
        connectError = '';
      }
      if (!(this instanceof FtpReconnectError)) {
        throw new TypeError("FtpReconnectError constructor called without 'new' keyword");
      }
      this.name = 'FtpReconnectError';
      this.disconnectError = disconnectError;
      this.connectError = connectError;
      prefix = "Error automatically reconnecting to server";
      suffix = "Triggering disconnect error";
      if (onCwd) {
        mainMsg = "Could not preserve CWD";
      } else {
        mainMsg = "Could not connect to server";
      }
      this.message = prefix + ".  " + mainMsg + ": " + this.connectError + ".  " + suffix + ": " + this.disconnectError + ".";
      connectErrorStack = "" + (this.connectError.stack || this.connectError);
      if (connectErrorStack.slice(-1) !== '\n') {
        connectErrorStack += '\n';
      }
      disconnectErrorStack = "" + (this.disconnectError.stack || this.disconnectError);
      if (disconnectErrorStack.slice(-1) !== '\n') {
        disconnectErrorStack += '\n';
      }
      this.stack = this.name + ": " + prefix + ".\n" + mainMsg + ": " + connectErrorStack + suffix + ": " + disconnectErrorStack;
    }

    FtpReconnectError.prototype.disconnectError = null;

    FtpReconnectError.prototype.connectError = null;

    return FtpReconnectError;

  })(Error);

  module.exports = FtpReconnectError;

}).call(this);
