2024-10-24 05:19:48 -07:00
export class FilesNotFoundError extends Error {
2024-11-14 03:22:03 -08:00
files : string [ ]
2024-10-24 05:19:48 -07:00
2024-11-14 03:22:03 -08:00
constructor ( files : string [ ] = [ ] ) {
let message = 'No files were found to upload'
if ( files . length > 0 ) {
message += ` : ${ files . join ( ', ' ) } `
2024-10-24 05:19:48 -07:00
}
2024-11-14 03:22:03 -08:00
super ( message )
this . files = files
this . name = 'FilesNotFoundError'
}
2024-10-24 05:19:48 -07:00
}
export class InvalidResponseError extends Error {
2024-11-14 03:22:03 -08:00
constructor ( message : string ) {
super ( message )
this . name = 'InvalidResponseError'
}
2024-10-24 05:19:48 -07:00
}
export class CacheNotFoundError extends Error {
2024-11-14 03:22:03 -08:00
constructor ( message = 'Cache not found' ) {
super ( message )
this . name = 'CacheNotFoundError'
}
2024-10-24 05:19:48 -07:00
}
export class GHESNotSupportedError extends Error {
2024-11-14 03:22:03 -08:00
constructor (
message = '@actions/cache v4.1.4+, actions/cache/save@v4+ and actions/cache/restore@v4+ are not currently supported on GHES.'
) {
super ( message )
this . name = 'GHESNotSupportedError'
}
2024-10-24 05:19:48 -07:00
}
export class NetworkError extends Error {
2024-11-14 03:22:03 -08:00
code : string
2024-10-24 05:19:48 -07:00
2024-11-14 03:22:03 -08:00
constructor ( code : string ) {
const message = ` Unable to make request: ${ code } \ nIf you are using self-hosted runners, please make sure your runner has access to all GitHub endpoints: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/about-self-hosted-runners#communication-between-self-hosted-runners-and-github `
super ( message )
this . code = code
this . name = 'NetworkError'
}
2024-10-24 05:19:48 -07:00
2024-11-14 03:22:03 -08:00
static isNetworkErrorCode = ( code? : string ) : boolean = > {
if ( ! code ) return false
return [
'ECONNRESET' ,
'ENOTFOUND' ,
'ETIMEDOUT' ,
'ECONNREFUSED' ,
'EHOSTUNREACH'
] . includes ( code )
}
2024-10-24 05:19:48 -07:00
}
export class UsageError extends Error {
2024-11-14 03:22:03 -08:00
constructor ( ) {
const message = ` Cache storage quota has been hit. Unable to upload any new cache entries. Usage is recalculated every 6-12 hours. \ nMore info on storage limits: https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#calculating-minute-and-storage-spending `
super ( message )
this . name = 'UsageError'
}
2024-10-24 05:19:48 -07:00
2024-11-14 03:22:03 -08:00
static isUsageErrorMessage = ( msg? : string ) : boolean = > {
if ( ! msg ) return false
return msg . includes ( 'insufficient usage' )
}
2024-10-24 05:19:48 -07:00
}