1
1
import LinkHeader from 'http-link-header' ;
2
- import { StatusError } from 'itty-router' ;
3
2
4
- import { Logger } from '@gitbook/runtime' ;
3
+ import { Logger , ExposableError } from '@gitbook/runtime' ;
5
4
6
5
import type { GithubRuntimeContext , GitHubSpaceConfiguration } from './types' ;
7
6
import { assertIsDefined , getSpaceConfigOrThrow } from './utils' ;
@@ -343,7 +342,7 @@ async function requestGitHubAPI(
343
342
logger . error ( `[${ options . method } ] (${ response . status } ) GitHub API error: ${ text } ` ) ;
344
343
345
344
// Otherwise, we throw an error
346
- throw new StatusError ( response . status , `GitHub API error: ${ response . statusText } ` ) ;
345
+ throw new ExposableError ( `GitHub API error: ${ response . statusText } ` , response . status ) ;
347
346
}
348
347
349
348
return response ;
@@ -370,7 +369,7 @@ async function refreshCredentials(
370
369
371
370
if ( ! resp . ok ) {
372
371
// If refresh fails for whatever reason, we ask the user to re-authenticate
373
- throw new StatusError ( 401 , `Unauthorized: kindly re-authenticate!` ) ;
372
+ throw new ExposableError ( `Unauthorized: kindly re-authenticate!` , 401 ) ;
374
373
}
375
374
376
375
const data = await resp . formData ( ) ;
@@ -398,7 +397,7 @@ export function extractTokenCredentialsOrThrow(
398
397
399
398
const oAuthCredentials = config ?. oauth_credentials ;
400
399
if ( ! oAuthCredentials ?. access_token ) {
401
- throw new StatusError ( 401 , 'Unauthorized: kindly re-authenticate!' ) ;
400
+ throw new ExposableError ( 'Unauthorized: kindly re-authenticate!' , 401 ) ;
402
401
}
403
402
404
403
return oAuthCredentials ;
0 commit comments