Skip to content

Commit cb002c6

Browse files
author
sasdf
committed
App not exist exception
App not exist exception
1 parent 8576b35 commit cb002c6

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

coder-base/server.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,23 @@ var querystring = require('querystring');
3535

3636
var loadApp = function( loadpath ) {
3737

38-
var userapp = null;
39-
if ( config.cacheApps ) {
40-
userapp = require(loadpath);
41-
} else {
38+
try{
39+
var userapp = null;
40+
if ( config.cacheApps ) {
41+
userapp = require(loadpath);
42+
} else {
4243

43-
var cached = require.cache[loadpath + '.js'];
44-
if ( cached ) {
45-
userapp = require(loadpath);
46-
if ( userapp.on_destroy ) {
47-
userapp.on_destroy();
48-
}
49-
delete require.cache[loadpath + ".js"];
50-
}
51-
userapp = require(loadpath);
52-
}
44+
var cached = require.cache[loadpath + '.js'];
45+
if ( cached ) {
46+
userapp = require(loadpath);
47+
if ( userapp.on_destroy ) {
48+
userapp.on_destroy();
49+
}
50+
delete require.cache[loadpath + ".js"];
51+
}
52+
userapp = require(loadpath);
53+
}
54+
} catch ( err ) { userapp = null; }
5355
return userapp;
5456
};
5557

@@ -60,9 +62,13 @@ var apphandler = function( req, res, appdir ) {
6062
var apppath = req.params[1];
6163
var modpath = appdir + appname;
6264
var userapp = loadApp( modpath + "/app" );
63-
6465

6566
util.log( "GET: " + apppath + " " + appname );
67+
68+
if ( userapp === null ) {
69+
res.send('app not found.');
70+
return;
71+
}
6672

6773
//Redirect to sign-in for unauthenticated users
6874
publicAllowed = ["auth"]; //apps that are exempt from any login (should only be auth)

0 commit comments

Comments
 (0)