!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/local/lib/node_modules/pm2/node_modules/continuation-local-storage/test/   drwxr-xr-x
Free 13.2 GB of 57.97 GB (22.78%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     error-handling.tap.js (4.19 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
'use strict';

var test   = require('tap').test
  , cls    = require('../context.js')
  , domain = require('domain')
  ;

test("continuation-local storage glue with a throw in the continuation chain",
     function (t) {
  var namespace = cls.createNamespace('test');
  namespace.run(function () {
    var d = domain.create();
    namespace.set('outer', true);
    namespace.bindEmitter(d);

    d.on('error', function (blerg) {
      t.equal(blerg.message, "explicitly nonlocal exit", "got the expected exception");
      t.ok(namespace.get('outer'), "outer context is still active");
      t.notOk(namespace.get('inner'), "inner context should have been exited by throw");
      t.equal(namespace._set.length, 1, "should be back to outer state");

      cls.destroyNamespace('test');
      t.end();
    });

    // tap is only trying to help
    process.nextTick(d.bind(function () {
      t.ok(namespace.get('outer'), "outer mutation worked");
      t.notOk(namespace.get('inner'), "inner mutation hasn't happened yet");

      namespace.run(function () {
        namespace.set('inner', true);
        throw new Error("explicitly nonlocal exit");
      });
    }));
  });
});

test("synchronous throw attaches the context", function (t) {
  t.plan(3);

  var namespace = cls.createNamespace('cls@synchronous');
  namespace.run(function () {
    namespace.set('value', 'transaction clear');
    try {
      namespace.run(function () {
        namespace.set('value', 'transaction set');
        throw new Error('cls@synchronous explosion');
      });
    }
    catch (e) {
      t.ok(namespace.fromException(e), "context was attached to error");
      t.equal(namespace.fromException(e)['value'], 'transaction set',
              "found the inner value");
    }

    t.equal(namespace.get('value'), 'transaction clear', "everything was reset");
  });

  cls.destroyNamespace('cls@synchronous');
});

test("synchronous throw checks if error exists", function (t) {
  t.plan(2);

  var namespace = cls.createNamespace('cls@synchronous-null-error');
  namespace.run(function () {
    namespace.set('value', 'transaction clear');
    try {
      namespace.run(function () {
        namespace.set('value', 'transaction set');
        throw null;
      });
    }
    catch (e) {
      // as we had a null error, cls couldn't set the new inner value
      t.equal(namespace.get('value'), 'transaction clear', 'from outer value');
    }

    t.equal(namespace.get('value'), 'transaction clear', "everything was reset");
  });

  cls.destroyNamespace('cls@synchronous-null-error');
});

test("throw in process.nextTick attaches the context", function (t) {
  t.plan(3);

  var namespace = cls.createNamespace('cls@nexttick');
  var d = domain.create();
  namespace.bindEmitter(d);

  d.on('error', function (e) {
    t.ok(namespace.fromException(e), "context was attached to error");
    t.equal(namespace.fromException(e)['value'], 'transaction set',
            "found the inner value");

    cls.destroyNamespace('cls@nexttick');
  });

  namespace.run(function () {
    namespace.set('value', 'transaction clear');

    // tap is only trying to help
    process.nextTick(d.bind(function () {
      namespace.run(function () {
        namespace.set('value', 'transaction set');
        throw new Error("cls@nexttick explosion");
      });
    }));

    t.equal(namespace.get('value'), 'transaction clear', "everything was reset");
  });
});

test("throw in setTimeout attaches the context", function (t) {
  t.plan(3);

  var namespace = cls.createNamespace('cls@setTimeout');
  var d = domain.create();
  namespace.bindEmitter(d);

  d.on('error', function (e) {
    t.ok(namespace.fromException(e), "context was attached to error");
    t.equal(namespace.fromException(e)['value'], 'transaction set',
            "found the inner value");

    cls.destroyNamespace('cls@setTimeout');
  });

  namespace.run(function () {
    namespace.set('value', 'transaction clear');

    // tap is only trying to help
    setTimeout(d.bind(function () {
      namespace.run(function () {
        namespace.set('value', 'transaction set');
        throw new Error("cls@setTimeout explosion");
      });
    }));

    t.equal(namespace.get('value'), 'transaction clear', "everything was reset");
  });
});

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.005 ]--