-
Notifications
You must be signed in to change notification settings - Fork 52
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
feat(react-query): add cli error handling #1388
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
948f078
feat(react-query): add logger
gwansikk d4213ce
feat(react-query): improve cli error handling
gwansikk ebb0389
Merge branch 'main' into react-query/feature/cli-error-handling
gwansikk 3ca00c1
fix(logger): change error logging to use console.error
gwansikk 6b7f53f
Create few-news-push.md
manudeli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { logger } from './logger' | ||
|
||
describe('logger', () => { | ||
const LOG_PREFIX = '[@suspensive/react-query]' | ||
const consoleLogSpy = vi.spyOn(console, 'log').mockClear() | ||
const consoleErrorSpy = vi.spyOn(console, 'error').mockClear() | ||
|
||
beforeEach(() => { | ||
vi.resetModules() | ||
vi.clearAllMocks() | ||
}) | ||
|
||
it('should log a message with console.log', () => { | ||
const testMessage = 'test message' | ||
logger.log(testMessage) | ||
|
||
expect(consoleLogSpy).toHaveBeenCalledWith(LOG_PREFIX, testMessage) | ||
}) | ||
|
||
it('should log a error with console.warn', () => { | ||
const testMessage = 'error message' | ||
logger.error(testMessage) | ||
|
||
expect(consoleErrorSpy).toHaveBeenCalledWith(LOG_PREFIX, testMessage) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const LOG_PREFIX = '[@suspensive/react-query]' | ||
|
||
export const logger = { | ||
log: (message: string) => console.log(LOG_PREFIX, message), | ||
error: (message: string) => console.error(LOG_PREFIX, message), | ||
} | ||
Comment on lines
+3
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All CLI logs are handled through the logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { copy } from './copy' | ||
import { logger } from './logger' | ||
|
||
export function switchVersion(version: number) { | ||
const result = copy(version) | ||
|
||
if (result) { | ||
console.log('[@suspensive/react-query]', `switched to version v${version}`) | ||
logger.log(`switched to version v${version}`) | ||
} else { | ||
console.warn('[@suspensive/react-query]', 'not found version files.') | ||
logger.error('not found version files.') | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All throw Errors occurring during the CLI process are handled by the designated error boundary