V
V
vasIvas2014-12-19 14:56:41
JavaScript
vasIvas, 2014-12-19 14:56:41

Why doesn't custom error class work in Gulp plugin?

Here is index.js code

var Test = require( './test.js' );

function MyPlugin( ){
  var test = new Test( );
  test.myProblem( );

  return through2.obj( );
}

Here is test.js
'use strict';

module.exports = Test;

function TestError( message ){
  Error.call( this, message );
}

TestError.prototype = Object.create( Error.prototype );
TestError.prototype.constructor = TestError;

function Test( ){}

Test.prototype = {
  constructor: Test,

  myProblem: function( ){
    // throw new Error( "[method myProblem]ERROR!!!" ); // так работает
    throw new TestError( "[method myProblem]" ); // так нет, почему?
  }
}

Question in the comments.
UPD: if you run the code with pure nodejs, then the code works.
It does not work only when gulp it through its commands to nodejs executes it.
This is probably a bug, since it generally hurts both gulp and nodejs.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
P
PedroGarciyaLopez, 2014-12-19
@PedroGarciyaLopez

and so?

function TestError( message ){
        this.message = message;
    }

    TestError.prototype = Error.prototype;

A
Artyom Karetnikov, 2017-05-02
@dimka11

1. A table is made: tbl_Order - here you have an order header, date, customer details, etc., which is not repeated.
2. A table is made: tbl_OrderDetail - id, id_order, id_product
Everything, any number of goods in the order and a minimum of duplicate fields, and they are int.

E
entermix, 2017-05-02
@entermix

offers
id, name, ...
orders
id, ...
order_items
id, order_id, offer_id, ...

V
Viktor Yanyshev, 2017-05-02
@villiwalla

Table relationships
1st stage of normalization

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question