<commit_before>%%%--------------------------------------------------------------------
%%% @author <NAME>
%%% @copyright (C) 2015 ACK CYFRONET AGH
%%% This software is released under the MIT license
%%% cited in 'LICENSE.txt'.
%%% @end
%%%--------------------------------------------------------------------
%%% @doc
%%% Exception handler for cdmi operations.
%%% It behaves as follows:
%% TODO describe handler behaviour, so far it's copied from requeste_exception_handler
%%% * for exception of integer type terminates request with given integer as
%%%   http status
%%% * for exception of {integer, term()} type terminates request with given
%%%   integer as http status, and given term converted to json as body
%%% * for any other exception terminates request with 500 http code and logs
%%%   error with stacktrace
%%% @end
%%%--------------------------------------------------------------------
-module(cdmi_exception_handler).
-author("<NAME>").

-include_lib("ctool/include/logging.hrl").
-include("modules/http_worker/rest/http_status.hrl").

%% Function that translates handler exception to cowboy format
-type exception_handler() ::
fun((Req :: cowboy_req:req(), State :: term(), Type :: atom(), Error :: term()) -> term()).

-export_type([exception_handler/0]).

%% API
-export([handle/4]).

%%%===================================================================
%%% API
%%%===================================================================

%%--------------------------------------------------------------------
%% @doc
%% this handler returns appropriate cowboy status on basis of caught exception.<commit_msg>VFS-1401 - error_test starts and fails<commit_after>%%%--------------------------------------------------------------------
%%% @author <NAME>
%%% @copyright (C) 2015 ACK CYFRONET AGH
%%% This software is released under the MIT license
%%% cited in 'LICENSE.txt'.
%%% @end
%%%--------------------------------------------------------------------
%%% @doc
%%% Exception handler for cdmi operations.
%%% It behaves as follows:
%% TODO describe handler behaviour, so far it's copied from requeste_exception_handler
%%% * for exception of integer type terminates request with given integer as
%%%   http status
%%% * for exception of {integer, term()} type terminates request with given
%%%   integer as http status, and given term converted to json as body
%%% * for any other exception terminates request with 500 http code and logs
%%%   error with stacktrace
%%% @end
%%%--------------------------------------------------------------------
-module(cdmi_exception_handler).
-author("<NAME>").

-include_lib("ctool/include/logging.hrl").
-include("modules/http_worker/rest/http_status.hrl").

%% Function that translates handler exception to cowboy format
-type exception_handler() ::
fun((Req :: cowboy_req:req(), State :: term(), Type :: atom(), Error :: term()) -> term()).

-export_type([exception_handler/0]).

%% API
-export([handle/4]).


%%%===================================================================
%%% API
%%%===================================================================

%%--------------------------------------------------------------------
%% @doc
%% this handler returns appropriate cowboy status on basis of caught exception.
{'fraction_non_alphanumeric': 0.36119585112873703, 'fraction_numerical': 0.006711409395973154, 'mean_word_length': 2.4049844236760123, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4938275', 'n_tokens_mistral': 774, 'n_tokens_neox': 732, 'n_words': 265}