Skip to content

Commit 2c7cb62

Browse files
author
sasdf
committed
App not exist exception
1 parent 99b70ee commit 2c7cb62

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

coder-base/server.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,22 @@ var querystring = require('querystring');
3636
var loadApp = function( loadpath ) {
3737

3838
var userapp = null;
39-
if ( config.cacheApps ) {
40-
userapp = require(loadpath);
41-
} else {
39+
try{
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

@@ -61,6 +63,10 @@ var apphandler = function( req, res, appdir ) {
6163
var modpath = appdir + appname;
6264
var userapp = loadApp( modpath + "/app" );
6365

66+
if ( userapp === null ) {
67+
res.send( 'App not found.' );
68+
return;
69+
}
6470

6571
util.log( "GET: " + apppath + " " + appname );
6672

0 commit comments

Comments
 (0)