Exception: ConvenientService::Exception

Inherits:
StandardError
  • Object
show all
Defined in:
lib/convenient_service/exception.rb

Overview

Base class for all ConvenientService exceptions.

Examples:

Can be used as a catch-all solution.


begin
  any_service.result
rescue ConvenientService::Exception => exception
  puts exception.message
end

Direct Known Subclasses

Common::Plugins::CanHaveCallbacks::Exceptions::AroundCallbackChainIsNotContinued, Common::Plugins::CanHaveUserProvidedEntity::Exceptions::ProtoEntityHasNoConcern, Common::Plugins::CanHaveUserProvidedEntity::Exceptions::ProtoEntityHasNoName, Core::Entities::Config::Exceptions::ConfigIsCommitted, Core::Entities::Config::Exceptions::TooManyCommitsFromMethodMissing, Feature::Plugins::CanHaveEntries::Exceptions::NotDefinedEntryMethod, RSpec::Helpers::Classes::WrapMethod::Exceptions::ChainAttributePreliminaryAccess, RSpec::Matchers::Classes::Results::Base::Exceptions::InvalidStep, RSpec::PrimitiveHelpers::Classes::IgnoringException::Exceptions::IgnoredExceptionIsNotRaised, RSpec::PrimitiveMatchers::Classes::DelegateTo::Exceptions::ArgumentsChainingIsAlreadySet, RSpec::PrimitiveMatchers::Classes::DelegateTo::Exceptions::CallOriginalChainingIsAlreadySet, RSpec::PrimitiveMatchers::Classes::DelegateTo::Exceptions::ReturnCustomValueChainingInvalidArguments, RSpec::PrimitiveMatchers::Classes::DelegateTo::Exceptions::ReturnValueChainingIsAlreadySet, Service::Plugins::CanHaveConnectedSteps::Exceptions::EmptyExpressionHasNoResult, Service::Plugins::CanHaveConnectedSteps::Exceptions::EmptyExpressionHasNoStatus, Service::Plugins::CanHaveConnectedSteps::Exceptions::FirstGroupStepIsNotSet, Service::Plugins::CanHaveConnectedSteps::Exceptions::FirstStepIsNotSet, Service::Plugins::CanHaveConnectedSteps::Exceptions::ServiceHasNoSteps, Service::Plugins::CanHaveFallbacks::Exceptions::FallbackResultIsNotOverridden, Service::Plugins::CanHaveFallbacks::Exceptions::ServiceFallbackReturnValueNotSuccess, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::MethodHasNoOrganizer, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::MethodIsNotOutputMethod, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::OutMethodStepIsNotCompleted, Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer, Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepResultDataNotExistingAttribute, Service::Plugins::CanHaveSteps::Entities::Step::Plugins::CanBeMethodStep::Exceptions::MethodForStepIsNotDefined, Service::Plugins::CanHaveSteps::Entities::Step::Plugins::CanBeMethodStep::Exceptions::StepIsNotMethodStep, Service::Plugins::CanHaveSteps::Entities::Step::Plugins::CanBeServiceStep::Exceptions::StepIsNotServiceStep, Service::Plugins::CanHaveSteps::Entities::Step::Plugins::CanHaveFallbacks::Exceptions::FallbackResultIsNotOverridden, Service::Plugins::CanHaveSteps::Entities::Step::Plugins::CanHaveFallbacks::Exceptions::MethodStepCanNotHaveFallback, Service::Plugins::CanHaveSteps::Entities::Step::Plugins::HasResult::Exceptions::StepHasUnknownType, Service::Plugins::CanHaveSteps::Entities::Step::Plugins::RaisesOnNotResultReturnValue::Exceptions::ReturnValueNotKindOfResult, Service::Plugins::CanNotBeInherited::Exceptions::ServiceIsInherited, Service::Plugins::ForbidsConvenientServiceEntitiesAsConstructorArguments::Exceptions::ResultPassedAsConstructorArgument, Service::Plugins::ForbidsConvenientServiceEntitiesAsConstructorArguments::Exceptions::ServicePassedAsConstructorArgument, Service::Plugins::ForbidsConvenientServiceEntitiesAsConstructorArguments::Exceptions::StepPassedAsConstructorArgument, Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Exceptions::ErrorHasNoOtherTypeRepresentation, Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Exceptions::NotExistingAttribute, Service::Plugins::HasJSendResult::Entities::Result::Plugins::HelpsToLearnSimilaritiesWithCommonObjects::Exceptions::ErrorHasNoOtherTypeRepresentation, Service::Plugins::HasJSendResult::Entities::Result::Plugins::RaisesOnNotCheckedResultStatus::Exceptions::StatusIsNotChecked, Service::Plugins::HasJSendResultShortSyntax::Error::Exceptions::BothArgsAndKwargsArePassed, Service::Plugins::HasJSendResultShortSyntax::Error::Exceptions::KwargsContainJSendAndExtraKeys, Service::Plugins::HasJSendResultShortSyntax::Error::Exceptions::MoreThanTwoArgsArePassed, Service::Plugins::HasJSendResultShortSyntax::Failure::Exceptions::BothArgsAndKwargsArePassed, Service::Plugins::HasJSendResultShortSyntax::Failure::Exceptions::KwargsContainJSendAndExtraKeys, Service::Plugins::HasJSendResultShortSyntax::Failure::Exceptions::MoreThanTwoArgsArePassed, Service::Plugins::HasJSendResultShortSyntax::Success::Exceptions::KwargsContainJSendAndExtraKeys, Service::Plugins::HasNegatedResult::Exceptions::NegatedResultIsNotOverridden, Service::Plugins::HasResult::Exceptions::ResultIsNotOverridden, Service::Plugins::RaisesOnDoubleResult::Exceptions::DoubleResult, Service::Plugins::RaisesOnNotResultReturnValue::Exceptions::ReturnValueNotKindOfResult, Support::AbstractMethod::Exceptions::AbstractMethodNotOverridden, Support::Arguments::Exceptions::InvalidKeyType, Support::Cache::Exceptions::NotSupportedBackend, Support::Castable::Exceptions::CastIsNotOverridden, Support::Castable::Exceptions::FailedToCast, Support::Command::Exceptions::CallIsNotOverridden, Support::Counter::Exceptions::ValueAfterDecrementIsLowerThanMinValue, Support::Counter::Exceptions::ValueAfterIncrementIsGreaterThanMaxValue, Support::DependencyContainer::Exceptions::InvalidScope, Support::DependencyContainer::Exceptions::NotExportableModule, Support::DependencyContainer::Exceptions::NotExportedMethod, Support::DependencyContainer::Exceptions::NotModule, Support::FiniteLoop::Exceptions::MaxIterationCountExceeded, Support::FiniteLoop::Exceptions::NoBlockGiven, Support::Middleware::StackBuilder::Entities::Builders::Rack::Exceptions::MissingMiddleware, Support::Middleware::StackBuilder::Entities::Builders::Stateful::Exceptions::MissingMiddleware, Support::Middleware::StackBuilder::Exceptions::NotSupportedBackend, Support::NeverReachHere, Utils::Array::Exceptions::NonIntegerIndex

Class Method Summary collapse

Class Method Details

.newConvenientService::Exception .new(message) ⇒ ConvenientService::Exception .new(**kwargs) ⇒ ConvenientService::Exception

Note:

initialize_with_kwargs or initialize_without_arguments must call initialize(message), otherwise exception instance won't be properly set up.

Creates ConvenientService exception instance. In contract to StandardError.new, may accept kwargs. In such a case the descendant must implement initialize_with_kwargs to specify the logic of how to generate a message. Without arguments behavior is also changed, it calls initialize_without_arguments instead of immediately setting nil as message.

Overloads:



81
82
83
84
85
86
87
88
89
# File 'lib/convenient_service/exception.rb', line 81

def new(message = nil, **kwargs)
  if message
    super(message)
  elsif kwargs.any?
    allocate.tap { |exception| exception.initialize_with_kwargs(**kwargs) }
  else
    allocate.tap(&:initialize_without_arguments)
  end
end