swc/tests/fixture/issue-1515/case1/input/input.ts
강동윤 99f4f0f280
fix(swc): Fix bugs for v1.2.52 (#1506)
swc_ecma_parser:
 - Support `private declare`. (#1503)
 - Recover `backtracking` state while doing some nested backtracking. (#1505)
 - Allow using `readonly` as the name of class properties. (#1514)

swc_ecma_transforms_base:
 - `hygiene`: Keep the name of class expressions. (#1507)

swc_ecma_transforms_typescript:
 - Allow a namespace and a class to have the same name. (#1515)

swc:
 - Disable `tsx` if the ext of a file is ts.
2021-03-29 20:48:48 +09:00

28 lines
865 B
TypeScript

export class ServiceError extends Error {
readonly code: ServiceError.Code = ServiceError.Code.badResponse;
readonly name: string = "ServiceError.BadResponse";
}
export namespace ServiceError {
export const enum Code {
serviceNotFound = 404,
serviceNotCompatible = 426,
serviceGone = 410,
implementation = 500,
timedOut = 504,
badRequest = 400,
badResponse = 422,
}
export class ServiceNotFound extends ServiceError {
// Service was probably not registered, or using the wrong channel
readonly code = Code.serviceNotFound;
readonly name = "ServiceError.ServiceNotFound";
}
export function toMessageBody(
error: unknown,
): { code: number; message?: string; stack?: string } {
return { code: ServiceError.Code.implementation };
}
}