Commit 3c7ade5d authored by Johannes Bill's avatar Johannes Bill

fixed error propagaytion

parent b79718bf
{
"restApiHost": "127.0.0.1",
"restApiPort": 3001,
"mysqlConfig": {
"host": "127.0.0.1",
"port": 3306,
"database": "gemeindeschluessel",
"username": "root",
"password": "bla"
}
}
\ No newline at end of file
var mysql = require('mysql');
var http = require('http'); var http = require('http');
var config = require('../config.json');
var hostname = "127.0.0.1"; var hostname = config["restApiHost"];
var port = 3001; var port = config["restApiPort"];
var headers = {
"Content-Type": "application/json",
"Connection": "keep-alive"
};
var blndMapping = { var blndMapping = {
"Baden-Württemberg": "BW", "Baden-Württemberg": "BW",
...@@ -26,6 +23,10 @@ var blndMapping = { ...@@ -26,6 +23,10 @@ var blndMapping = {
"Thüringen": "TH" "Thüringen": "TH"
}; };
var headers = {
"Content-Type": "application/json",
"Connection": "keep-alive"
};
function request(path, cb) { function request(path, cb) {
var options = { var options = {
hostname: hostname, hostname: hostname,
...@@ -47,6 +48,7 @@ function request(path, cb) { ...@@ -47,6 +48,7 @@ function request(path, cb) {
var req = http.request(options, callback); var req = http.request(options, callback);
req.on("error", function (err) { req.on("error", function (err) {
err = new Error('Could not connect to: ' + hostname + path );
cb(err); cb(err);
}); });
req.setTimeout(500, function () { req.setTimeout(500, function () {
...@@ -88,7 +90,7 @@ module.exports.getKatholisch = function(plz, cb) { ...@@ -88,7 +90,7 @@ module.exports.getKatholisch = function(plz, cb) {
return cb(err); return cb(err);
} }
if (feiertag === undefined) if (feiertag === undefined)
return cb(new Error("no religion entry found for plz " + plz)); return cb(new Error("no entry found in religion table for plz " + plz));
cb(null, !!feiertag); cb(null, !!feiertag);
}) })
}; };
......
...@@ -91,7 +91,8 @@ function wrapper(_epochSpan) { ...@@ -91,7 +91,8 @@ function wrapper(_epochSpan) {
} }
function getDaySpan(data) { function getDaySpan(data) {
var dayoption = parseInt(data["dayoption"]["0"]); var dayoptionS = data["dayoption"]["0"];
var dayoption = parseInt(dayoptionS);
if (dayoption < 7) return [dayoption, dayoption]; if (dayoption < 7) return [dayoption, dayoption];
switch (dayoption) { switch (dayoption) {
case 7: case 7:
...@@ -103,7 +104,7 @@ function wrapper(_epochSpan) { ...@@ -103,7 +104,7 @@ function wrapper(_epochSpan) {
case 10: case 10:
return [1, 6]; return [1, 6];
default: default:
throw new Error("Invalid day option: " + dayoption); throw new Error("Invalid day option: " + dayoptionS);
} }
} }
......
var holidayMapping = require('./holidayMapping.json'); var holidayMapping = require('./holidayMapping.json');
var easterSunday = require('./easterSunday'); var easterSunday = require('./easterSunday');
var restRequest = require('./restRequests'); var restRequest = require('./blndRelRequest');
var SimplQueue = require('./simplQueue'); var SimplQueue = require('./simplQueue');
var easterSundays = {}; var easterSundays = {};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment