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::CanHaveUserProvidedEntity::Exceptions::ProtoEntityHasNoConcern, Common::Plugins::CanHaveUserProvidedEntity::Exceptions::ProtoEntityHasNoName, Common::Plugins::HasAroundCallbacks::Exceptions::AroundCallbackChainIsNotContinued, 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::Entities::Matcher::Entities::ChainingsCollection::Exceptions::ArgumentsChainingIsAlreadySet, RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::Matcher::Entities::ChainingsCollection::Exceptions::CallOriginalChainingIsAlreadySet, RSpec::PrimitiveMatchers::Classes::DelegateTo::Entities::Matcher::Entities::ChainingsCollection::Exceptions::ReturnItsValueChainingIsAlreadySet, Service::Plugins::CanHaveFallbacks::Exceptions::FallbackResultIsNotOverridden, Service::Plugins::CanHaveFallbacks::Exceptions::ServiceFallbackReturnValueNotSuccess, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::AliasInputMethodIsNotDefinedInContainer, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::AliasOutputMethodIsDefinedInContainer, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::CallerCanNotCalculateReassignment, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::InputMethodIsNotDefinedInContainer, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::InputMethodReassignment, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::MethodHasNoOrganizer, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::MethodIsNotInputMethod, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::MethodIsNotOutputMethod, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::NotCompletedStep, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::NotExistingStepResultDataAttribute, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::OutputMethodIsDefinedInContainer, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::OutputMethodProc, Service::Plugins::CanHaveSteps::Entities::Method::Exceptions::OutputMethodRawValue, Service::Plugins::CanHaveSteps::Entities::Step::Exceptions::StepHasNoOrganizer, Service::Plugins::CanHaveSteps::Entities::Step::Plugins::CanBeResultStep::CanBeExecuted::Exceptions::MethodForStepIsNotDefined, Service::Plugins::CanHaveSteps::Entities::Step::Plugins::RaisesOnNotResultReturnValue::Exceptions::ReturnValueNotKindOfResult, Service::Plugins::HasJSendResult::Entities::Result::Plugins::HasJSendStatusAndAttributes::Exceptions::NotExistingAttribute, Service::Plugins::HasJSendResult::Entities::Result::Plugins::RaisesOnNotCheckedResultStatus::Exceptions::StatusIsNotChecked, Service::Plugins::HasJSendResult::Exceptions::ResultIsNotOverridden, 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::HasResult::Exceptions::ResultIsNotOverridden, Service::Plugins::RaisesOnDoubleResult::Exceptions::DoubleResult, Service::Plugins::RaisesOnNotResultReturnValue::Exceptions::ReturnValueNotKindOfResult, Support::AbstractMethod::Exceptions::AbstractMethodNotOverridden, 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, 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:

  • .newConvenientService::Exception

    This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

    Calls initialize_without_arguments under the hood to generate the exception message.

    Examples:

    Usage.

    module Exceptions
      class Foo < ::ConvenientService::Exception
        def initialize_without_arguments
          # message = ...
          initialize(message)
        end
      end
    end
    
    ::ConvenientService.raise Foo.new
    

    Returns:

  • .new(message) ⇒ ConvenientService::Exception

    This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

    Calls initialize(message) under the hood to set the exception message.

    Examples:

    Usage.

    module Exceptions
      class Foo < ::ConvenientService::Exception
      end
    end
    
    ::ConvenientService.raise Foo.new("some message")
    

    Parameters:

    • message (String)

    Returns:

  • .new(**kwargs) ⇒ ConvenientService::Exception

    This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

    Calls initialize_with_kwargs(**kwargs) under the hood to generate the exception message.

    Examples:

    Usage.

    module Exceptions
      class Foo < ::ConvenientService::Exception
        def initialize_with_kwargs(**kwargs)
          # message = ...
          initialize(message)
        end
      end
    end
    
    ::ConvenientService.raise Foo.new(foo: :bar, baz: :qux)
    

    Parameters:

    • kwargs (Hash{Symbol => Object})

    Returns:



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