Module: LogStruct::Integrations::Sorbet
- Extended by:
- IntegrationInterface, T::Sig
- Defined in:
- lib/log_struct/integrations/sorbet.rb
Overview
Integration for Sorbet runtime type checking error handlers This module installs error handlers that report type errors through LogStruct These handlers can be enabled/disabled using configuration
Class Method Summary collapse
-
.setup(config) ⇒ Boolean?
Set up Sorbet error handlers to report errors through LogStruct.
Methods included from IntegrationInterface
Class Method Details
.setup(config) ⇒ Boolean?
Set up Sorbet error handlers to report errors through LogStruct
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/log_struct/integrations/sorbet.rb', line 17 def self.setup(config) return nil unless config.integrations.enable_sorbet_error_handlers # Install inline type error handler # Called when T.let, T.cast, T.must, etc. fail T::Configuration.inline_type_error_handler = lambda do |error, _opts| LogStruct.handle_exception(error, source: LogStruct::Source::TypeChecking) end # Install call validation error handler # Called when method signature validation fails T::Configuration.call_validation_error_handler = lambda do |_signature, opts| error = TypeError.new(opts[:pretty_message]) LogStruct.handle_exception(error, source: LogStruct::Source::TypeChecking) end # Install sig builder error handler # Called when there's a problem with a signature definition T::Configuration.sig_builder_error_handler = lambda do |error, _location| LogStruct.handle_exception(error, source: LogStruct::Source::TypeChecking) end # Install sig validation error handler # Called when there's a problem with a signature validation T::Configuration.sig_validation_error_handler = lambda do |error, _opts| LogStruct.handle_exception(error, source: LogStruct::Source::TypeChecking) end true end |