Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error handling to date formatting functions #960

Merged
merged 4 commits into from
Apr 1, 2023

Conversation

dudantas
Copy link
Member

@dudantas dudantas commented Mar 28, 2023

Description

This adds try/catch blocks to the formatDate and formatDateShort functions to handle potential errors when formatting dates. In case of an error, the functions will log an error message and return an empty string. This change improves the robustness of the code and prevents potential crashes when passing invalid values to the functions.

Behaviour

Actual

Do this and that doesn't happens

Expected

Do this and that happens

Fixes

# (issue)

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A
  • Test B

Test Configuration:

  • Server Version:
  • Client:
  • Operating System:

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

dudantas and others added 2 commits March 28, 2023 17:58
Thi adds try/catch blocks to the formatDate and formatDateShort functions to handle potential errors when formatting dates. In case of an error, the functions will log an error message using the SPDLOG_ERROR macro and return an empty string. This change improves the robustness of the code and prevents potential crashes when passing invalid values to the functions.
@dudantas dudantas linked an issue Mar 28, 2023 that may be closed by this pull request
5 tasks
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

0.0% 0.0% Coverage
12.6% 12.6% Duplication

@opentibiabr opentibiabr deleted a comment from travisani Mar 30, 2023
@opentibiabr opentibiabr deleted a comment from dudantas Mar 30, 2023
@opentibiabr opentibiabr deleted a comment from travisani Mar 30, 2023
@dudantas dudantas merged commit 0f02e94 into opentibiabr:main Apr 1, 2023
luan pushed a commit that referenced this pull request Jul 11, 2023
This adds try/catch blocks to the formatDate and formatDateShort functions to handle potential errors when formatting dates. In case of an error, the functions will log an error message and return an empty string. This change improves the robustness of the code and prevents potential crashes when passing invalid values to the functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Depo crashed server
4 participants