Comments (7)
@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.
@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.
@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.
@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.
@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.
You also might want to read http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony
from microformat-node.
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)
- Error when parsing http://www.boemiadigital.com/
- Error when parsing 'http://www.limitedtoendodontics.com'
- Error when parsing www.markgordondentistry.com HOT 1
- Parsing an h-entry with a root of <article> results in an empty h-entry HOT 3
- parseUrl promise not working HOT 2
- parseDom (feature request) HOT 4
- p-name breaks on empty text HOT 5
- Remove or separate out parseUrl() to slim down library? HOT 4
- Can't find '../test/testWriter.js' from bin/microformat-node HOT 2
- HTML entity handling HOT 3
- Update microformat-shiv dependency reference HOT 1
- Regression in text parsing of weird XSS:ish content?
- crash on certain input HOT 2
- Truncated Dates (bday / without years) are not parsed HOT 2
- Backcompat parsing conflicts
- Some URL's causes library to "hang"
- href ignored for u-* properties HOT 1
- Alternative node/JS microformats parser
- Dependency "ent" uses deprecated Node punycode module HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from microformat-node.