@@ -1251,12 +1251,29 @@ exports.userGitHubRepoListPage = function (aReq, aRes, aNext) {
1251
1251
}
1252
1252
1253
1253
function asyncComplete ( aErr ) {
1254
+ var msg = null ;
1255
+
1254
1256
if ( aErr ) {
1255
- console . error ( aErr ) ;
1256
- statusCodePage ( aReq , aRes , aNext , {
1257
- statusCode : 500 ,
1258
- statusMessage : 'Server Error'
1259
- } ) ;
1257
+ switch ( aErr . code ) {
1258
+ case 403 :
1259
+ try {
1260
+ msg = JSON . parse ( aErr . message ) ;
1261
+ } catch ( aE ) {
1262
+ msg = { message : aErr . message } ;
1263
+ }
1264
+ console . warn ( msg . message ) ;
1265
+ statusCodePage ( aReq , aRes , aNext , {
1266
+ statusCode : 503 ,
1267
+ statusMessage : 'Service unavailable. Please check back later.'
1268
+ } ) ;
1269
+ break ;
1270
+ default :
1271
+ console . error ( aErr ) ;
1272
+ statusCodePage ( aReq , aRes , aNext , {
1273
+ statusCode : 500 ,
1274
+ statusMessage : 'Server Error'
1275
+ } ) ;
1276
+ }
1260
1277
return ;
1261
1278
}
1262
1279
@@ -1378,8 +1395,29 @@ exports.userGitHubRepoPage = function (aReq, aRes, aNext) {
1378
1395
}
1379
1396
1380
1397
function asyncComplete ( aErr ) {
1398
+ var msg = null ;
1399
+
1381
1400
if ( aErr ) {
1382
- aNext ( ) ;
1401
+ switch ( aErr . code ) {
1402
+ case 403 :
1403
+ try {
1404
+ msg = JSON . parse ( aErr . message ) ;
1405
+ } catch ( aE ) {
1406
+ msg = { message : aErr . message } ;
1407
+ }
1408
+ console . warn ( msg . message ) ;
1409
+ statusCodePage ( aReq , aRes , aNext , {
1410
+ statusCode : 503 ,
1411
+ statusMessage : 'Service unavailable. Please check back later.'
1412
+ } ) ;
1413
+ break ;
1414
+ default :
1415
+ console . error ( aErr ) ;
1416
+ statusCodePage ( aReq , aRes , aNext , {
1417
+ statusCode : 500 ,
1418
+ statusMessage : 'Server Error'
1419
+ } ) ;
1420
+ }
1383
1421
return ;
1384
1422
}
1385
1423
@@ -1411,7 +1449,7 @@ exports.userGitHubRepoPage = function (aReq, aRes, aNext) {
1411
1449
if ( process . env . DISABLE_SCRIPT_IMPORT === 'true' ) {
1412
1450
statusCodePage ( aReq , aRes , aNext , {
1413
1451
statusCode : 503 ,
1414
- statusMessage : 'Service unavailable. Please check back later'
1452
+ statusMessage : 'Service unavailable. Please check back later. '
1415
1453
} ) ;
1416
1454
return ;
1417
1455
}
@@ -1715,6 +1753,7 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) {
1715
1753
] , function ( aErr ) {
1716
1754
var script = null ;
1717
1755
var code = null ;
1756
+ var msg = null ;
1718
1757
1719
1758
if ( aErr ) {
1720
1759
code = ( aErr instanceof statusError ? aErr . status . code : aErr . code ) ;
@@ -1727,20 +1766,35 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) {
1727
1766
}
1728
1767
1729
1768
if ( ! ( aErr instanceof String ) ) {
1730
- statusCodePage ( aReq , aRes , aNext , {
1731
- statusCode : ( aErr instanceof statusError ? aErr . status . code : aErr . code ) ,
1732
- statusMessage : ( aErr instanceof statusError ? aErr . status . message : aErr . message ) ,
1733
- isCustomView : true ,
1734
- statusData : {
1735
- isGHImport : true ,
1736
- utf_pathname : githubPathName ,
1737
- utf_pathext : githubPathExt ,
1738
- user : encodeURIComponent ( githubUserId ) ,
1739
- repo : encodeURIComponent ( githubRepoName ) ,
1740
- default_branch : encodeURIComponent ( githubDefaultBranch ) ,
1741
- path : encodeURIComponent ( githubBlobPath )
1742
- }
1743
- } ) ;
1769
+ switch ( aErr . code ) { // NOTE: Important to test for GH 403 vs potential OUJS 403
1770
+ case 403 :
1771
+ try {
1772
+ msg = JSON . parse ( aErr . message ) ;
1773
+ } catch ( aE ) {
1774
+ msg = { message : aErr . message } ;
1775
+ }
1776
+ console . warn ( msg . message ) ;
1777
+ statusCodePage ( aReq , aRes , aNext , {
1778
+ statusCode : 503 ,
1779
+ statusMessage : 'Service unavailable. Please check back later.'
1780
+ } ) ;
1781
+ break ;
1782
+ default :
1783
+ statusCodePage ( aReq , aRes , aNext , {
1784
+ statusCode : ( aErr instanceof statusError ? aErr . status . code : aErr . code ) ,
1785
+ statusMessage : ( aErr instanceof statusError ? aErr . status . message : aErr . message ) ,
1786
+ isCustomView : true ,
1787
+ statusData : {
1788
+ isGHImport : true ,
1789
+ utf_pathname : githubPathName ,
1790
+ utf_pathext : githubPathExt ,
1791
+ user : encodeURIComponent ( githubUserId ) ,
1792
+ repo : encodeURIComponent ( githubRepoName ) ,
1793
+ default_branch : encodeURIComponent ( githubDefaultBranch ) ,
1794
+ path : encodeURIComponent ( githubBlobPath )
1795
+ }
1796
+ } ) ;
1797
+ }
1744
1798
} else {
1745
1799
statusCodePage ( aReq , aRes , aNext , {
1746
1800
statusCode : 500 ,
0 commit comments