@@ -35,21 +35,23 @@ var querystring = require('querystring');
35
35
36
36
var loadApp = function ( loadpath ) {
37
37
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 {
42
43
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 ; }
53
55
return userapp ;
54
56
} ;
55
57
@@ -60,9 +62,13 @@ var apphandler = function( req, res, appdir ) {
60
62
var apppath = req . params [ 1 ] ;
61
63
var modpath = appdir + appname ;
62
64
var userapp = loadApp ( modpath + "/app" ) ;
63
-
64
65
65
66
util . log ( "GET: " + apppath + " " + appname ) ;
67
+
68
+ if ( userapp === null ) {
69
+ res . send ( 'app not found.' ) ;
70
+ return ;
71
+ }
66
72
67
73
//Redirect to sign-in for unauthenticated users
68
74
publicAllowed = [ "auth" ] ; //apps that are exempt from any login (should only be auth)
0 commit comments