Skip to content

Commit a12af73

Browse files
committed
fix docs
1 parent 9797e9b commit a12af73

File tree

4 files changed

+37
-21
lines changed

4 files changed

+37
-21
lines changed

examples/configuration.rb

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,26 +98,29 @@ def self.configuration_examples
9898
# END CODE EXAMPLE: filter_configuration
9999
# ----------------------------------------------------------
100100

101+
# rubocop:disable Layout/ExtraSpacing
101102
# ----------------------------------------------------------
102103
# BEGIN CODE EXAMPLE: error_handling_modes
103104
# ----------------------------------------------------------
104105
# Configure error handling modes
105106
modes = config.error_handling_modes
106-
modes.logstruct_errors = LogStruct::ErrorHandlingMode::Log
107-
modes.security_errors = LogStruct::ErrorHandlingMode::Report
108-
modes.standard_errors = LogStruct::ErrorHandlingMode::LogProduction
109-
modes.type_checking_errors = LogStruct::ErrorHandlingMode::Raise
107+
modes.type_checking_errors = LogStruct::ErrorHandlingMode::ReportProduction
108+
modes.logstruct_errors = LogStruct::ErrorHandlingMode::ReportProduction
109+
modes.security_errors = LogStruct::ErrorHandlingMode::Report
110+
modes.standard_errors = LogStruct::ErrorHandlingMode::Raise
110111

111-
# Available error handling modes:
112+
# Error handling modes:
113+
# ------------------------------------------------------------
114+
# Ignore: Ignore the error
115+
# Log: Log the error
116+
# Report: Log and report to tracking service without crashing
117+
# LogProduction: Log error in production, raise during dev/test
118+
# ReportProduction: Report in production without crashing, raise during dev/test
119+
# Raise: Always raise the error (reported by tracking service)
112120
# ------------------------------------------------------------
113-
# ::Ignore # Completely ignore errors
114-
# ::Log # Log errors but don't report them
115-
# ::LogProduction # Log in production, raise in development
116-
# ::Report # Log and report errors to error service
117-
# ::Raise # Always raise errors
118-
# ----------------------------------------------------------
119121
# END CODE EXAMPLE: error_handling_modes
120122
# ----------------------------------------------------------
123+
# rubocop:enable Layout/ExtraSpacing
121124
end
122125
end
123126
end

examples/type_safety.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def self.type_safety_examples
2222
)
2323

2424
# Log the typed struct
25-
Rails.logger.info(request_log)
25+
LogStruct.log(request_log)
2626

2727
# Create a typed error log entry
2828
error_log = LogStruct::Log::Error.new(
@@ -32,7 +32,7 @@ def self.type_safety_examples
3232
)
3333

3434
# Log the error
35-
Rails.logger.error(error_log)
35+
LogStruct.log(error_log)
3636
# ----------------------------------------------------------
3737
# END CODE EXAMPLE: basic_typed_logging
3838
# ----------------------------------------------------------

lib/log_struct/config_struct/error_handling_modes.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ class ErrorHandlingModes < T::Struct
88

99
# How to handle different types of errors
1010
# Modes:
11-
# - :ignore - always ignore the error
12-
# - :log - always log the error
13-
# - :report - always report to tracking service and continue
14-
# - :log_production - log in production, raise locally
15-
# - :report_production - report in production, raise locally
16-
# - :raise - always raise regardless of environment
11+
# - Ignore - Ignore the error
12+
# - Log - Log the error
13+
# - Report - Log and report to error tracking service (but don't crash)
14+
# - LogProduction - Log error in production, raise locally (dev/test)
15+
# - ReportProduction - Report error in production, raise locally (dev/test)
16+
# - Raise - Always raise the error
1717

1818
# Configurable error handling categories
1919
prop :type_checking_errors, ErrorHandlingMode, default: ErrorHandlingMode::LogProduction

site/app/docs/configuration/page.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { RubyCodeExample } from '@/components/ruby-code-example';
22
import { EditPageLink } from '@/components/edit-page-link';
33
import { CodeBlock } from '@/components/code-block';
44
import { HeadingWithAnchor } from '@/components/heading-with-anchor';
5+
import Link from 'next/dist/client/link';
56

67
export default function ConfigurationPage() {
78
return (
@@ -59,8 +60,20 @@ export default function ConfigurationPage() {
5960
Error Handling Configuration
6061
</HeadingWithAnchor>
6162
<p className="text-neutral-600 dark:text-neutral-400 mb-4">
62-
LogStruct provides different error handling modes to control how errors
63-
are processed:
63+
LogStruct provides customizable error handling modes to control how
64+
errors are processed. You probably don&apos;t want type-checking errors
65+
or internal logging-related errors to crash your application, so our
66+
default behavior is to log and report those errors without crashing. We
67+
automatically detect which error reporting service you use (Sentry,
68+
Bugsnag, Rollbar, etc.). If you use a service that we don&apos;t support
69+
yet, you can configure a{' '}
70+
<Link
71+
className="text-gray-200 hover:underline"
72+
href="#custom-error-reporting"
73+
>
74+
custom error handler
75+
</Link>
76+
. (Or you can send a PR!)
6477
</p>
6578

6679
<RubyCodeExample name="error_handling_modes" />

0 commit comments

Comments
 (0)