Add more details to exception - #541
Conversation
Log errors from field manager packet processing Add pending state to channels
WalkthroughThe changes introduce refined error handling and logging across several server management classes, including adjustments to exception flows and log details. The channel management logic is updated to support a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant ChannelClientLookup
participant Channel
Client->>ChannelClientLookup: FindOrCreateChannelByIp(ip, instancedContent)
alt Channel with Inactive status exists
ChannelClientLookup->>Channel: Set status to Pending
ChannelClientLookup-->>Client: Return Pending channel
else No suitable channel
ChannelClientLookup->>Channel: Create new channel with Pending status
ChannelClientLookup-->>Client: Return new Pending channel
end
Note over ChannelClientLookup,Channel: MonitorChannel may transition Pending <-> Active/Inactive
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
Maple2.Database/Storage/Game/GameStorage.Nurturing.cs(1 hunks)Maple2.Server.Game/Manager/Field/FieldManager/FieldManager.cs(1 hunks)Maple2.Server.Game/Manager/HousingManager.cs(1 hunks)Maple2.Server.Game/Manager/Items/InventoryManager.cs(2 hunks)Maple2.Server.Game/Manager/MailManager.cs(3 hunks)Maple2.Server.World/Containers/ChannelClientLookup.cs(7 hunks)
🧰 Additional context used
🧠 Learnings (2)
Maple2.Database/Storage/Game/GameStorage.Nurturing.cs (1)
Learnt from: Zintixx
PR: AngeloTadeucci/Maple2#279
File: Maple2.Database/Storage/Game/GameStorage.Wedding.cs:147-159
Timestamp: 2024-10-13T18:10:08.059Z
Learning: In the `GameStorage` class in `Maple2.Database/Storage/Game/GameStorage.Wedding.cs`, the `GetMarriage` method is necessary to properly convert the `Marriage` object and initialize `Partner1` and `Partner2`.
Maple2.Server.Game/Manager/Field/FieldManager/FieldManager.cs (2)
Learnt from: AngeloTadeucci
PR: AngeloTadeucci/Maple2#199
File: Maple2.Server.Game/PacketHandlers/FileHandler.cs:0-0
Timestamp: 2024-10-09T04:13:28.776Z
Learning: Packets can't ever be null inside the `Handle` function of packet handlers in the repository.
Learnt from: AngeloTadeucci
PR: AngeloTadeucci/Maple2#199
File: Maple2.Server.Game/PacketHandlers/FileHandler.cs:0-0
Timestamp: 2024-07-12T04:31:25.376Z
Learning: Packets can't ever be null inside the `Handle` function of packet handlers in the repository.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: build
🔇 Additional comments (12)
Maple2.Database/Storage/Game/GameStorage.Nurturing.cs (1)
22-22: LGTM! Logical improvement to timestamp initialization.Setting
LastFeedTimeto the current time when creating a new nurturing record is more appropriate than usingDateTime.MinValue. This provides a meaningful baseline for tracking feeding activity.Maple2.Server.Game/Manager/Items/InventoryManager.cs (1)
463-464: LGTM! Enhanced diagnostic logging.Adding both item UID and item ID to the error logs and exception messages provides better diagnostic information for debugging item consumption failures. The consistent format across both failure scenarios is well implemented.
Also applies to: 476-477
Maple2.Server.Game/Manager/HousingManager.cs (1)
717-718: LGTM! Improved error handling with graceful failure.Replacing the exception throw with error logging and returning
falseprovides better stability and controlled error handling. This aligns with the method's boolean return type and prevents unhandled exceptions from crashing the application.Maple2.Server.Game/Manager/Field/FieldManager/FieldManager.cs (1)
279-284: LGTM! Robust exception handling for packet processing.The comprehensive exception handling distinguishes between expected
IndexOutOfRangeException(logged without stack trace) and unexpected exceptions (logged with full details). Including opcode, account ID, and packet details provides excellent diagnostic information while preventing field crashes from packet processing failures.Maple2.Server.Game/Manager/MailManager.cs (2)
9-9: LGTM! Added proper logging infrastructure.Adding Serilog support with a scoped logger provides the foundation for improved error diagnostics throughout the mail management system.
Also applies to: 24-24
211-212: LGTM! Improved error handling with controlled failure.Replacing the exception throw with error logging and returning
MailError.s_mail_error_receiveitem_to_invenprovides better stability and aligns with the method's error code return type. The detailed logging includes mail ID and item information for effective debugging.Maple2.Server.World/Containers/ChannelClientLookup.cs (6)
26-30: Good addition of thePendingstate for better channel lifecycle management.The intermediate state helps prevent race conditions during channel activation.
79-87: The removed attribute was not applicable to value types.Since
channelIdis anint(value type), the[NotNullWhen(true)]attribute removal doesn't affect functionality. Value types are never null.
146-146: Correct initialization withPendingstatus.Initializing new channels with
Pendingstatus aligns with the new lifecycle management approach.
168-174: Proper handling ofPendingstate transitions.The monitoring logic correctly allows channels to transition from
Pendingto eitherActiveorInactivebased on health check results.
265-267: Formatting change only.
272-295: Class relocation follows common C# conventions.
Log errors from field manager packet processing
Add pending state to channels
Summary by CodeRabbit
Bug Fixes
New Features
Other Improvements