Giter VIP home page Giter VIP logo

Comments (7)

voxpelli avatar voxpelli commented on July 23, 2024 1

@Janpot Chill :) @sebilasse is just offering a workaround for you and others that experience this issue, no need to be rude. Strangers can't possibly know your skill level and even then – issues may affect more people than the one reporting it. Instead you could maybe check if #37 actually fixes this issue?

from microformat-node.

sebilasse avatar sebilasse commented on July 23, 2024

@Janpot
It is absolutely fine reporting this errors - will look into this one as well.
The above hentry is invalid off course, dt- SHOULD be anything, e.g. valid <time> with class="dt-published" ...

Regarding your

"also happening on"

: If you you use it in production :
Use it in a try {} catch (error) {} block to return an empty mf-object instead of an Unknown Error

Your example above could become :

var Microformats = require('microformat-node');
function getMFnoUnknownError(o, cb) {
  try {
    return Microformats.get(o, cb);
  } catch (err) {
    return (!(cb)) ? {"items":[{"type":["h-item"],"properties":{}}],"rels":{},"rel-urls":{}} :
    cb(null, {"items":[{"type":["h-item"],"properties":{}}],"rels":{},"rel-urls":{}});
  }
}
// same use as above :
getMFnoUnknownError({
  html: '<div class="hentry"><div class="dt-">0AM<div class="dt-">x</div></div></div>'
}, function (err, data) {
   console.log(err, data);
});

Another suggestion - you might want to log "the whole" error, apart from node's built in stuff, you could simply use this function instead console.log(err) :

function dumpError(err: any) {
  if (typeof err === 'object') {
    if (err.message) {
      console.log('\nERROR Message: ' + err.message)
    }
    if (err.stack) {
      console.log('\nStacktrace:')
      console.log('====================')
      console.log(err.stack);
    }
  } else {
    console.log('dumpError :: argument is not an object');
  }
}

use it in the above callback as

function (err, data) {
  dumpError(err);
  console.log('DATA:', data);
});

it returns

ERROR Message: Cannot set property '0' of undefined

Stacktrace:
====================
TypeError: Cannot set property '0' of undefined
    at modules.Parser.impliedDate (MY/node_modules/microformat-node/lib/index.js:1645:61)
    at modules.Parser.impliedRules (MY/node_modules/microformat-node/lib/index.js:1514:15)
    at modules.Parser.walkTree (MY/node_modules/microformat-node/lib/index.js:597:11)
    at modules.Parser.walkRoot (MY/node_modules/microformat-node/lib/index.js:553:18)
    at modules.Parser.walkRoot (MY/node_modules/microformat-node/lib/index.js:564:23)
    at modules.Parser.get (MY/node_modules/microformat-node/lib/index.js:88:19)
    at Object.External.get (MY/node_modules/microformat-node/lib/index.js:4508:33)
    at IndieAuth.test (MY/_build/src/auth/IndieAuth/main.js:114:30)
    at MY/_build/src/auth/test2.js:38:52
    at MY/_build/src/auth/test2.js:3:17
    at Object.<anonymous> (MY/_build/src/auth/test2.js:8:3)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)

from microformat-node.

Janpot avatar Janpot commented on July 23, 2024

@sebilasse I just dumbed the program down to the smallest possible code that reproduces the problem. It's nice of you to start teaching me how to code, but you're wasting your time here.

from microformat-node.

sebilasse avatar sebilasse commented on July 23, 2024

@Janpot You realized that I fixed both issue apart from saying "in production for foreign code always use try/catch". And as @voxpelli said: It is not about you it is about everyone.
@voxpelli As usual : Rude Open-Source-Consumers, nice indieweb-people ;)

from microformat-node.

Janpot avatar Janpot commented on July 23, 2024

@sebilasse @voxpelli That's why I started by saying "It's nice of you to start teaching me how to code". Because I don't mean to be rude.

from microformat-node.

Janpot avatar Janpot commented on July 23, 2024

You also might want to read http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony

from microformat-node.

glennjones avatar glennjones commented on July 23, 2024

Hi @Janpot thanks for finding this issue and providing the example and @sebilasse for providing the the fix. I have updated the underlying parsing and add a new test.

Its now in microformats-node v2.0.1

Any other problems let me known

Glenn

from microformat-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.