Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | 7x 7x 4x 10x 4x 7x 4x 4x 7x 1x 1x 6x 7x 1x 1x 1x 5x 7x 1x 1x 1x 4x 7x 1x 1x 1x 3x 7x 3x 7x 4x | interface ErrorStatus {
status: string
statusCode: number
}
export const errors = {
BadRequest: {
status: 'BadRequest',
statusCode: 400,
},
Unauthorized: {
status: 'Unauthorized',
statusCode: 401,
},
Forbidden: {
status: 'Forbidden',
statusCode: 403,
},
NotFound: {
status: 'NotFound',
statusCode: 404,
},
}
export function findAndThrowError(response: Response): never | void {
[ BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError ].forEach(error => {
if (error.match(response)) {
throw new error(response)
}
})
}
export class HttpError extends Error {
protected static statusCode: number
public constructor(errorStatus: ErrorStatus) {
super(`${errorStatus.statusCode} ${errorStatus.status}`)
this.name = 'Http Error'
}
}
export class BadRequestError extends HttpError {
private path: string
public constructor(response: Response) {
super(errors.BadRequest)
this.path = response.url
}
public static match(response: Response): boolean {
return response.status === errors.BadRequest.statusCode
}
}
export class UnauthorizedError extends HttpError {
private path: string
public constructor(response: Response) {
super(errors.Unauthorized)
this.name = errors.Unauthorized.status
this.path = response.url
}
public static match(response: Response): boolean {
return response.status === errors.Unauthorized.statusCode
}
}
export class ForbiddenError extends HttpError {
private path: string
public constructor(response: Response) {
super(errors.Forbidden)
this.name = errors.Forbidden.status
this.path = response.url
}
public static match(response: Response): boolean {
return response.status === errors.Forbidden.statusCode
}
}
export class NotFoundError extends HttpError {
private path: string
public constructor(response: Response) {
super(errors.NotFound)
this.name = errors.NotFound.status
this.path = response.url
}
public static match(response: Response): boolean {
return response.status === errors.NotFound.statusCode
}
}
/**
* Is thrown if --single is specified, but no binary was found
*/
export class NoChromiumDownloadError extends Error {
public constructor() {
super('Single version is specified, but no binary is found')
}
}
export class NoLocalstoreError extends Error {
public constructor(path?: string) {
super(`No "localstore.json" file found${path != null ? ' under the given path: ' + path : ''}`)
}
}
|