aboutsummaryrefslogtreecommitdiff
path: root/src/api/structures/Server.js
diff options
context:
space:
mode:
authorZephyrrus <[email protected]>2020-07-20 21:29:06 +0300
committerZephyrrus <[email protected]>2020-07-20 21:29:06 +0300
commit6fee07d9e15fb785721d9c6870231f1d0c95f10c (patch)
tree93ffe32cc9954c29fba48aef080e01fd8ed923ff /src/api/structures/Server.js
parentfeat: add single tag adding to file (diff)
downloadhost.fuwn.me-6fee07d9e15fb785721d9c6870231f1d0c95f10c.tar.xz
host.fuwn.me-6fee07d9e15fb785721d9c6870231f1d0c95f10c.zip
fix: don't crash the server if a route fails to load
Diffstat (limited to 'src/api/structures/Server.js')
-rw-r--r--src/api/structures/Server.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/api/structures/Server.js b/src/api/structures/Server.js
index 7f1b4d5..e25e089 100644
--- a/src/api/structures/Server.js
+++ b/src/api/structures/Server.js
@@ -70,9 +70,13 @@ class Server {
let routes = [RouteClass];
if (Array.isArray(RouteClass)) routes = RouteClass;
for (const File of routes) {
- const route = new File();
- this.server[route.method](process.env.ROUTE_PREFIX + route.path, route.authorize.bind(route));
- log.info(`Found route ${route.method.toUpperCase()} ${process.env.ROUTE_PREFIX}${route.path}`);
+ try {
+ const route = new File();
+ this.server[route.method](process.env.ROUTE_PREFIX + route.path, route.authorize.bind(route));
+ log.info(`Found route ${route.method.toUpperCase()} ${process.env.ROUTE_PREFIX}${route.path}`);
+ } catch (e) {
+ log.error(`Failed loading route from file ${routeFile} with error: ${e.message}`);
+ }
}
});
}