From c4e30c5fddd3a2c28431913e32f4a24744185eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wieland=20Sch=C3=B6bl?= Date: Tue, 2 Apr 2019 11:52:48 +0200 Subject: [PATCH] docs: add blank line before @param --- src/core/protocol/errors/ErrorResponse.ts | 44 +++++++++++++++++++ .../routes/plugin/PluginRegisterRequest.ts | 20 ++++++--- .../routes/plugin/PluginRegisterResponse.ts | 2 +- 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/src/core/protocol/errors/ErrorResponse.ts b/src/core/protocol/errors/ErrorResponse.ts index 93ae6e45..269c86f2 100644 --- a/src/core/protocol/errors/ErrorResponse.ts +++ b/src/core/protocol/errors/ErrorResponse.ts @@ -42,6 +42,7 @@ export abstract class SCError implements SCErrorResponse { /** * Instatiate an SCError + * * @param name Name of the error * @param message Message of the error * @param statusCode HTTP status code to return this error with @@ -66,6 +67,7 @@ export class SCValidationErrorResponse extends SCError { /** * Create a SCValidationErrorResponse + * * @param errors List of validation errors * @param stack Set to true if a stack trace should be created */ @@ -81,6 +83,7 @@ export class SCValidationErrorResponse extends SCError { export class SCUnsupportedMediaTypeErrorResponse extends SCError { /** * Create a SCUnsupportedMediaTypeErrorResponse + * * @param stack Set to true if a stack trace should be created */ constructor(stack?: boolean) { @@ -94,6 +97,7 @@ export class SCUnsupportedMediaTypeErrorResponse extends SCError { export class SCMethodNotAllowedErrorResponse extends SCError { /** * Create a SCMethodNotAllowedErrorResponse + * * @param stack Set to true if a stack trace should be created */ constructor(stack?: boolean) { @@ -120,6 +124,7 @@ export class SCRequestBodyTooLargeErrorResponse extends SCError { export class SCTooManyRequestsErrorResponse extends SCError { /** * Create a SCTooManyRequestsErrorResponse + * * @param stack Set to true if a stack trace should be created */ constructor(stack?: boolean) { @@ -133,6 +138,7 @@ export class SCTooManyRequestsErrorResponse extends SCError { export class SCNotFoundErrorResponse extends SCError { /** * Create a SCNotFoundErrorResponse + * * @param stack Set to true if a stack trace should be created */ constructor(stack?: boolean) { @@ -140,12 +146,46 @@ export class SCNotFoundErrorResponse extends SCError { } } +/** + * An error that is returned when the request is in the right format, but contains parameters that are invalid or not + * acceptable. + */ +export class SCParametersNotAcceptable extends SCError { + /** + * Create a ParametersNotAcceptable + * + * @param message contains more details to what you did wrong + * @param stack Set to true if a stack trace should be created + */ + constructor(message: string, stack?: boolean) { + super('ParametersNotAcceptable', message, 406, stack); + } +} + +/** + * An error that is returned when a plugin with the same name is already registered, to prevent two copies of a plugin + * running at the same time. + * This usually indicates that there is more than one instance a plugin running. + */ +export class SCPluginAlreadyRegisteredErrorResponse extends SCError { + /** + * Create a PluginAlreadyRegisteredError + * + * @param message contains potential differences in other parameters outside of the name + * @param stack Set to true if a stack trace should be created + */ + constructor(message: string, stack?: boolean) { + super('PluginRegisteringFailedError', message, 409, stack); + } +} + /** * An error that is returned whenever there is an unexpected error while creating a plugin */ export class SCPluginRegisteringFailedErrorResponse extends SCError { /** * Create a PluginRegisteringFailedError + * * @param message Describes what went wrong wile registering the plugin * @param stack Set to true if a stack trace should be created */ @@ -157,10 +197,12 @@ export class SCPluginRegisteringFailedErrorResponse extends SCError { /** * An error that is returned whenever there is a plugin request that is supposed to register a route, that is already * registered + * This usually indicates that two **different** plugins use the same route. */ export class SCPluginRouteAlreadyRegisteredErrorResponse extends SCError { /** * Create a PluginRouteAlreadyRegisteredError + * * @param registeredName The name by the plugin that has already registered the route previously * @param registeredUrl The URL by the plugin that has already registered the route previously * @param stack Set to true if a stack trace should be created @@ -177,6 +219,7 @@ export class SCPluginRouteAlreadyRegisteredErrorResponse extends SCError { export class SCSyntaxErrorResponse extends SCError { /** * Create a SyntaxError + * * @param message Describes the syntax error * @param stack Set to true if a stack trace should be created */ @@ -196,6 +239,7 @@ export class SCInternalServerErrorResponse extends SCError { /** * Create a SCInternalServerErrorResponse + * * @param err Internal server error * @param stack Set to true if a stack trace should be created * and the internal server error should be displayed to the client diff --git a/src/core/protocol/routes/plugin/PluginRegisterRequest.ts b/src/core/protocol/routes/plugin/PluginRegisterRequest.ts index dc9b5ec7..00a2c80c 100644 --- a/src/core/protocol/routes/plugin/PluginRegisterRequest.ts +++ b/src/core/protocol/routes/plugin/PluginRegisterRequest.ts @@ -16,7 +16,10 @@ import {Schema} from 'jsonschema'; import {SCAbstractRoute, SCRouteHttpVerbs} from '../../../Route'; import { SCInternalServerErrorResponse, - SCMethodNotAllowedErrorResponse, SCPluginRegisteringFailedErrorResponse, SCPluginRouteAlreadyRegisteredErrorResponse, + SCMethodNotAllowedErrorResponse, SCParametersNotAcceptable, + SCPluginAlreadyRegisteredErrorResponse, + SCPluginRegisteringFailedErrorResponse, + SCPluginRouteAlreadyRegisteredErrorResponse, SCRequestBodyTooLargeErrorResponse, SCSyntaxErrorResponse, } from '../../errors/ErrorResponse'; @@ -29,17 +32,17 @@ import { export type SCPluginRegisterRequest = AddPlugin | RemovePlugin; interface AddPlugin { /** - * The desired action, so whether the plugin should be added or removed. + * The desired action, so whether the plugin should be added or removed */ action: 'add'; /** - * The address of the plugin. + * The address of the plugin */ address: string; /** - * The name of the plugin. + * The name of the plugin * Just for debugging purposes, to more easily identify conflicts. */ name: string; @@ -55,13 +58,13 @@ interface AddPlugin { pluginResponseSchema: Schema; /** - * the desired route, for example /feedback. + * The desired route, for example /feedback. */ route: string; } interface RemovePlugin { /** - * The desired action, so whether the plugin should be added or removed. + * The desired action, so whether the plugin should be added or removed */ action: 'remove'; @@ -72,7 +75,7 @@ interface RemovePlugin { } /** - * Route to register Plugins + * Route to register plugins */ export class SCPluginRegisterRoute extends SCAbstractRoute { constructor() { @@ -80,6 +83,9 @@ export class SCPluginRegisterRoute extends SCAbstractRoute { this.errorNames = [ SCInternalServerErrorResponse, SCMethodNotAllowedErrorResponse, + SCParametersNotAcceptable, + SCPluginAlreadyRegisteredErrorResponse, + SCPluginRouteAlreadyRegisteredErrorResponse, SCPluginRegisteringFailedErrorResponse, SCPluginRouteAlreadyRegisteredErrorResponse, SCRequestBodyTooLargeErrorResponse, diff --git a/src/core/protocol/routes/plugin/PluginRegisterResponse.ts b/src/core/protocol/routes/plugin/PluginRegisterResponse.ts index 8bbad81a..7a4e43fe 100644 --- a/src/core/protocol/routes/plugin/PluginRegisterResponse.ts +++ b/src/core/protocol/routes/plugin/PluginRegisterResponse.ts @@ -20,7 +20,7 @@ */ export interface SCPluginRegisterResponse { /** - * Whether the desired action succeeded or failed (true for success, false if an error occurred). + * Whether the desired action succeeded or failed (true for success, false if an error occurred) */ success: boolean; }