mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-14 12:09:04 +08:00
Update restify-errors typings to support defined errors (#16382)
* Update restify-errors to correctly type predefined * Fixed linting errors * Fixed linting issue * Fixed defined types for restify-errors * Fixed restify-errors tests * Updated restify-errors ts version * Update correct definition * Remove unwanted file
This commit is contained in:
140
types/restify-errors/index.d.ts
vendored
140
types/restify-errors/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: http://www.restify.com
|
||||
// Definitions by: Steve Hipwell <https://github.com/stevehipwell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
import { VError, Options as vErrorOptions } from "verror";
|
||||
|
||||
@@ -36,6 +37,21 @@ export class HttpError extends VError {
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
export class DefinedHttpError extends HttpError {
|
||||
constructor();
|
||||
|
||||
// tslint:disable-next-line unified-signatures
|
||||
constructor(printf: string, ...args: any[]);
|
||||
|
||||
// tslint:disable-next-line unified-signatures
|
||||
constructor(options: RestifyHttpErrorOptions, printf?: string, ...args: any[]);
|
||||
|
||||
// tslint:disable-next-line unified-signatures
|
||||
constructor(priorErr: any, printf?: string, ...args: any[]);
|
||||
|
||||
constructor(priorErr: any, options: RestifyHttpErrorOptions, printf?: string, ...args: any[]);
|
||||
}
|
||||
|
||||
export interface RestifyRestErrorOptions extends RestifyHttpErrorOptions {
|
||||
restCode?: string;
|
||||
}
|
||||
@@ -53,67 +69,77 @@ export class RestError extends HttpError {
|
||||
restCode: string;
|
||||
}
|
||||
|
||||
export class DefinedRestError extends RestError {
|
||||
constructor();
|
||||
|
||||
// tslint:disable-next-line unified-signatures
|
||||
constructor(printf: string, ...args: any[]);
|
||||
|
||||
// tslint:disable-next-line unified-signatures
|
||||
constructor(options: RestifyHttpErrorOptions, printf?: string, ...args: any[]);
|
||||
|
||||
// tslint:disable-next-line unified-signatures
|
||||
constructor(priorErr: any, printf?: string, ...args: any[]);
|
||||
|
||||
constructor(priorErr: any, options: RestifyHttpErrorOptions, printf?: string, ...args: any[]);
|
||||
}
|
||||
|
||||
export function makeConstructor(name: string, defaults?: any): void;
|
||||
|
||||
export function makeErrFromCode(statusCode: number, ...args: any[]): HttpError;
|
||||
|
||||
export function bunyanSerializer(err: any): any;
|
||||
|
||||
export const HttpErrors: {
|
||||
BadRequestError: HttpError;
|
||||
UnauthorizedError: HttpError;
|
||||
PaymentRequiredError: HttpError;
|
||||
ForbiddenError: HttpError;
|
||||
NotFoundError: HttpError;
|
||||
MethodNotAllowedError: HttpError;
|
||||
NotAcceptableError: HttpError;
|
||||
ProxyAuthenticationRequiredError: HttpError;
|
||||
RequestTimeoutError: HttpError;
|
||||
ConflictError: HttpError;
|
||||
GoneError: HttpError;
|
||||
LengthRequiredError: HttpError;
|
||||
PreconditionFailedError: HttpError;
|
||||
RequestEntityTooLargeError: HttpError;
|
||||
RequesturiTooLargeError: HttpError;
|
||||
UnsupportedMediaTypeError: HttpError;
|
||||
RangeNotSatisfiableError: HttpError;
|
||||
ExpectationFailedError: HttpError;
|
||||
ImATeapotError: HttpError;
|
||||
UnprocessableEntityError: HttpError;
|
||||
LockedError: HttpError;
|
||||
FailedDependencyError: HttpError;
|
||||
UnorderedCollectionError: HttpError;
|
||||
UpgradeRequiredError: HttpError;
|
||||
PreconditionRequiredError: HttpError;
|
||||
TooManyRequestsError: HttpError;
|
||||
RequestHeaderFieldsTooLargeError: HttpError;
|
||||
InternalServerError: HttpError;
|
||||
NotImplementedError: HttpError;
|
||||
BadGatewayError: HttpError;
|
||||
ServiceUnavailableError: HttpError;
|
||||
GatewayTimeoutError: HttpError;
|
||||
HttpVersionNotSupportedError: HttpError;
|
||||
VariantAlsoNegotiatesError: HttpError;
|
||||
InsufficientStorageError: HttpError;
|
||||
BandwidthLimitExceededError: HttpError;
|
||||
NotExtendedError: HttpError;
|
||||
NetworkAuthenticationRequiredError: HttpError;
|
||||
};
|
||||
export class BadRequestError extends DefinedHttpError { }
|
||||
export class UnauthorizedError extends DefinedHttpError { }
|
||||
export class PaymentRequiredError extends DefinedHttpError { }
|
||||
export class ForbiddenError extends DefinedHttpError { }
|
||||
export class NotFoundError extends DefinedHttpError { }
|
||||
export class MethodNotAllowedError extends DefinedHttpError { }
|
||||
export class NotAcceptableError extends DefinedHttpError { }
|
||||
export class ProxyAuthenticationRequiredError extends DefinedHttpError { }
|
||||
export class RequestTimeoutError extends DefinedHttpError { }
|
||||
export class ConflictError extends DefinedHttpError { }
|
||||
export class GoneError extends DefinedHttpError { }
|
||||
export class LengthRequiredError extends DefinedHttpError { }
|
||||
export class PreconditionFailedError extends DefinedHttpError { }
|
||||
export class RequestEntityTooLargeError extends DefinedHttpError { }
|
||||
export class RequesturiTooLargeError extends DefinedHttpError { }
|
||||
export class UnsupportedMediaTypeError extends DefinedHttpError { }
|
||||
export class RangeNotSatisfiableError extends DefinedHttpError { }
|
||||
export class ExpectationFailedError extends DefinedHttpError { }
|
||||
export class ImATeapotError extends DefinedHttpError { }
|
||||
export class UnprocessableEntityError extends DefinedHttpError { }
|
||||
export class LockedError extends DefinedHttpError { }
|
||||
export class FailedDependencyError extends DefinedHttpError { }
|
||||
export class UnorderedCollectionError extends DefinedHttpError { }
|
||||
export class UpgradeRequiredError extends DefinedHttpError { }
|
||||
export class PreconditionRequiredError extends DefinedHttpError { }
|
||||
export class TooManyRequestsError extends DefinedHttpError { }
|
||||
export class RequestHeaderFieldsTooLargeError extends DefinedHttpError { }
|
||||
export class InternalServerError extends DefinedHttpError { }
|
||||
export class NotImplementedError extends DefinedHttpError { }
|
||||
export class BadGatewayError extends DefinedHttpError { }
|
||||
export class ServiceUnavailableError extends DefinedHttpError { }
|
||||
export class GatewayTimeoutError extends DefinedHttpError { }
|
||||
export class HttpVersionNotSupportedError extends DefinedHttpError { }
|
||||
export class VariantAlsoNegotiatesError extends DefinedHttpError { }
|
||||
export class InsufficientStorageError extends DefinedHttpError { }
|
||||
export class BandwidthLimitExceededError extends DefinedHttpError { }
|
||||
export class NotExtendedError extends DefinedHttpError { }
|
||||
export class NetworkAuthenticationRequiredError extends DefinedHttpError { }
|
||||
|
||||
export const RestErrors: {
|
||||
BadDigestError: RestError;
|
||||
BadMethodError: RestError;
|
||||
InternalError: RestError;
|
||||
InvalidArgumentError: RestError;
|
||||
InvalidContentError: RestError;
|
||||
InvalidCredentialsError: RestError;
|
||||
InvalidHeaderError: RestError;
|
||||
InvalidVersionError: RestError;
|
||||
MissingParameterError: RestError;
|
||||
NotAuthorizedError: RestError;
|
||||
PreconditionFailedError: RestError;
|
||||
RequestExpiredError: RestError;
|
||||
RequestThrottledError: RestError;
|
||||
ResourceNotFoundError: RestError;
|
||||
WrongAcceptError: RestError;
|
||||
};
|
||||
export class BadDigestError extends DefinedRestError { }
|
||||
export class BadMethodError extends DefinedRestError { }
|
||||
export class InternalError extends DefinedRestError { }
|
||||
export class InvalidArgumentError extends DefinedRestError { }
|
||||
export class InvalidContentError extends DefinedRestError { }
|
||||
export class InvalidCredentialsError extends DefinedRestError { }
|
||||
export class InvalidHeaderError extends DefinedRestError { }
|
||||
export class InvalidVersionError extends DefinedRestError { }
|
||||
export class MissingParameterError extends DefinedRestError { }
|
||||
export class NotAuthorizedError extends DefinedRestError { }
|
||||
export class RequestExpiredError extends DefinedRestError { }
|
||||
export class RequestThrottledError extends DefinedRestError { }
|
||||
export class ResourceNotFoundError extends DefinedRestError { }
|
||||
export class WrongAcceptError extends DefinedRestError { }
|
||||
|
||||
@@ -24,58 +24,57 @@ const customError = restifyErrors.makeErrFromCode(500, "Testing....");
|
||||
const bunyanSerializer = restifyErrors.bunyanSerializer;
|
||||
|
||||
// HttpErrors
|
||||
let httpError = restifyErrors.HttpErrors.BadRequestError;
|
||||
httpError = restifyErrors.HttpErrors.UnauthorizedError;
|
||||
httpError = restifyErrors.HttpErrors.PaymentRequiredError;
|
||||
httpError = restifyErrors.HttpErrors.ForbiddenError;
|
||||
httpError = restifyErrors.HttpErrors.NotFoundError;
|
||||
httpError = restifyErrors.HttpErrors.MethodNotAllowedError;
|
||||
httpError = restifyErrors.HttpErrors.NotAcceptableError;
|
||||
httpError = restifyErrors.HttpErrors.ProxyAuthenticationRequiredError;
|
||||
httpError = restifyErrors.HttpErrors.RequestTimeoutError;
|
||||
httpError = restifyErrors.HttpErrors.ConflictError;
|
||||
httpError = restifyErrors.HttpErrors.GoneError;
|
||||
httpError = restifyErrors.HttpErrors.LengthRequiredError;
|
||||
httpError = restifyErrors.HttpErrors.PreconditionFailedError;
|
||||
httpError = restifyErrors.HttpErrors.RequestEntityTooLargeError;
|
||||
httpError = restifyErrors.HttpErrors.RequesturiTooLargeError;
|
||||
httpError = restifyErrors.HttpErrors.UnsupportedMediaTypeError;
|
||||
httpError = restifyErrors.HttpErrors.RangeNotSatisfiableError;
|
||||
httpError = restifyErrors.HttpErrors.ExpectationFailedError;
|
||||
httpError = restifyErrors.HttpErrors.ImATeapotError;
|
||||
httpError = restifyErrors.HttpErrors.UnprocessableEntityError;
|
||||
httpError = restifyErrors.HttpErrors.LockedError;
|
||||
httpError = restifyErrors.HttpErrors.FailedDependencyError;
|
||||
httpError = restifyErrors.HttpErrors.UnorderedCollectionError;
|
||||
httpError = restifyErrors.HttpErrors.UpgradeRequiredError;
|
||||
httpError = restifyErrors.HttpErrors.PreconditionRequiredError;
|
||||
httpError = restifyErrors.HttpErrors.TooManyRequestsError;
|
||||
httpError = restifyErrors.HttpErrors.RequestHeaderFieldsTooLargeError;
|
||||
httpError = restifyErrors.HttpErrors.InternalServerError;
|
||||
httpError = restifyErrors.HttpErrors.NotImplementedError;
|
||||
httpError = restifyErrors.HttpErrors.BadGatewayError;
|
||||
httpError = restifyErrors.HttpErrors.ServiceUnavailableError;
|
||||
httpError = restifyErrors.HttpErrors.GatewayTimeoutError;
|
||||
httpError = restifyErrors.HttpErrors.HttpVersionNotSupportedError;
|
||||
httpError = restifyErrors.HttpErrors.VariantAlsoNegotiatesError;
|
||||
httpError = restifyErrors.HttpErrors.InsufficientStorageError;
|
||||
httpError = restifyErrors.HttpErrors.BandwidthLimitExceededError;
|
||||
httpError = restifyErrors.HttpErrors.NotExtendedError;
|
||||
httpError = restifyErrors.HttpErrors.NetworkAuthenticationRequiredError;
|
||||
let httpError = new restifyErrors.BadRequestError();
|
||||
httpError = new restifyErrors.UnauthorizedError();
|
||||
httpError = new restifyErrors.PaymentRequiredError();
|
||||
httpError = new restifyErrors.ForbiddenError();
|
||||
httpError = new restifyErrors.NotFoundError();
|
||||
httpError = new restifyErrors.MethodNotAllowedError();
|
||||
httpError = new restifyErrors.NotAcceptableError();
|
||||
httpError = new restifyErrors.ProxyAuthenticationRequiredError();
|
||||
httpError = new restifyErrors.RequestTimeoutError();
|
||||
httpError = new restifyErrors.ConflictError();
|
||||
httpError = new restifyErrors.GoneError();
|
||||
httpError = new restifyErrors.LengthRequiredError();
|
||||
httpError = new restifyErrors.PreconditionFailedError();
|
||||
httpError = new restifyErrors.RequestEntityTooLargeError();
|
||||
httpError = new restifyErrors.RequesturiTooLargeError();
|
||||
httpError = new restifyErrors.UnsupportedMediaTypeError();
|
||||
httpError = new restifyErrors.RangeNotSatisfiableError();
|
||||
httpError = new restifyErrors.ExpectationFailedError();
|
||||
httpError = new restifyErrors.ImATeapotError();
|
||||
httpError = new restifyErrors.UnprocessableEntityError();
|
||||
httpError = new restifyErrors.LockedError();
|
||||
httpError = new restifyErrors.FailedDependencyError();
|
||||
httpError = new restifyErrors.UnorderedCollectionError();
|
||||
httpError = new restifyErrors.UpgradeRequiredError();
|
||||
httpError = new restifyErrors.PreconditionRequiredError();
|
||||
httpError = new restifyErrors.TooManyRequestsError();
|
||||
httpError = new restifyErrors.RequestHeaderFieldsTooLargeError();
|
||||
httpError = new restifyErrors.InternalServerError();
|
||||
httpError = new restifyErrors.NotImplementedError();
|
||||
httpError = new restifyErrors.BadGatewayError();
|
||||
httpError = new restifyErrors.ServiceUnavailableError();
|
||||
httpError = new restifyErrors.GatewayTimeoutError();
|
||||
httpError = new restifyErrors.HttpVersionNotSupportedError();
|
||||
httpError = new restifyErrors.VariantAlsoNegotiatesError();
|
||||
httpError = new restifyErrors.InsufficientStorageError();
|
||||
httpError = new restifyErrors.BandwidthLimitExceededError();
|
||||
httpError = new restifyErrors.NotExtendedError();
|
||||
httpError = new restifyErrors.NetworkAuthenticationRequiredError();
|
||||
|
||||
// RestErrors
|
||||
let restError = restifyErrors.RestErrors.BadDigestError;
|
||||
restError = restifyErrors.RestErrors.BadMethodError;
|
||||
restError = restifyErrors.RestErrors.InternalError;
|
||||
restError = restifyErrors.RestErrors.InvalidArgumentError;
|
||||
restError = restifyErrors.RestErrors.InvalidContentError;
|
||||
restError = restifyErrors.RestErrors.InvalidCredentialsError;
|
||||
restError = restifyErrors.RestErrors.InvalidHeaderError;
|
||||
restError = restifyErrors.RestErrors.InvalidVersionError;
|
||||
restError = restifyErrors.RestErrors.MissingParameterError;
|
||||
restError = restifyErrors.RestErrors.NotAuthorizedError;
|
||||
restError = restifyErrors.RestErrors.PreconditionFailedError;
|
||||
restError = restifyErrors.RestErrors.RequestExpiredError;
|
||||
restError = restifyErrors.RestErrors.RequestThrottledError;
|
||||
restError = restifyErrors.RestErrors.ResourceNotFoundError;
|
||||
restError = restifyErrors.RestErrors.WrongAcceptError;
|
||||
let restError = new restifyErrors.BadDigestError();
|
||||
restError = new restifyErrors.BadMethodError();
|
||||
restError = new restifyErrors.InternalError();
|
||||
restError = new restifyErrors.InvalidArgumentError();
|
||||
restError = new restifyErrors.InvalidContentError();
|
||||
restError = new restifyErrors.InvalidCredentialsError();
|
||||
restError = new restifyErrors.InvalidHeaderError();
|
||||
restError = new restifyErrors.InvalidVersionError();
|
||||
restError = new restifyErrors.MissingParameterError();
|
||||
restError = new restifyErrors.NotAuthorizedError();
|
||||
restError = new restifyErrors.RequestExpiredError();
|
||||
restError = new restifyErrors.RequestThrottledError();
|
||||
restError = new restifyErrors.ResourceNotFoundError();
|
||||
restError = new restifyErrors.WrongAcceptError();
|
||||
|
||||
1
types/restify/index.d.ts
vendored
1
types/restify/index.d.ts
vendored
@@ -2,6 +2,7 @@
|
||||
// Project: https://github.com/mcavage/node-restify
|
||||
// Definitions by: Bret Little <https://github.com/blittle>, Steve Hipwell <https://github.com/stevehipwell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user