Skip to content

Commit

Permalink
add method not allowed error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
zamronypj committed Jan 7, 2020
1 parent 64b79e0 commit 48cd9c3
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/Error/MethodNotAllowedErrorHandlerImpl.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{*!
* Fano Web Framework (https://fanoframework.github.io)
*
* @link https://github.com/fanoframework/fano
* @copyright Copyright (c) 2018 Zamrony P. Juhara
* @license https://github.com/fanoframework/fano/blob/master/LICENSE (MIT)
*}

unit MethodNotAllowedErrorHandlerImpl;

interface

{$MODE OBJFPC}
{$H+}

uses

sysutils,
ErrorHandlerIntf,
EnvironmentEnumeratorIntf,
ConditionalErrorHandlerImpl;

type

(*!---------------------------------------------------
* error handler that handle EMethodNotAllowed exception
* or pass to default error handler
*
* @author Zamrony P. Juhara <zamronypj@yahoo.com>
*---------------------------------------------------*)
TMethodNotAllowedErrorHandler = class (TConditionalErrorHandler)
protected
function condition(
const env : ICGIEnvironmentEnumerator;
const exc : Exception;
const status : integer;
const msg : string
) : boolean; override;
end;

implementation

uses

EMethodNotAllowedImpl;

function TMethodNotAllowedErrorHandler.condition(
const env : ICGIEnvironmentEnumerator;
const exc : Exception;
const status : integer;
const msg : string
) : boolean;
begin
result := exc is EMethodNotAllowed;
end;
end.
1 change: 1 addition & 0 deletions src/Includes/Error/Implementations/error.aliases.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ TConditionalErrorHandler = ConditionalErrorHandlerImpl.TConditionalErrorHandler;
TDecoratorErrorHandler = DecoratorErrorHandlerImpl.TDecoratorErrorHandler;
TBoolErrorHandler = BoolErrorHandlerImpl.TBoolErrorHandler;
TNotFoundErrorHandler = NotFoundErrorHandlerImpl.TNotFoundErrorHandler;
TMethodNotAllowedErrorHandler = MethodNotAllowedErrorHandlerImpl.TMethodNotAllowedErrorHandler;

TFileLogErrorHandlerFactory = FileLogErrorHandlerFactoryImpl.TFileLogErrorHandlerFactory;
TProductionErrorHandlerFactory = ProductionErrorHandlerFactoryImpl.TProductionErrorHandlerFactory;
Expand Down
1 change: 1 addition & 0 deletions src/Includes/Error/Implementations/implementations.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ConditionalErrorHandlerImpl,
DecoratorErrorHandlerImpl,
BoolErrorHandlerImpl,
NotFoundErrorHandlerImpl,
MethodNotAllowedErrorHandlerImpl,

FileLogErrorHandlerFactoryImpl,
ProductionErrorHandlerFactoryImpl,
Expand Down

0 comments on commit 48cd9c3

Please sign in to comment.