-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(logger 🔧): task error logging (#454)
- Loading branch information
1 parent
b8f1f68
commit 5d0810b
Showing
27 changed files
with
180 additions
and
111 deletions.
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
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 was deleted.
Oops, something went wrong.
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,3 +1,2 @@ | ||
export { BettererError, isBettererError } from './error'; | ||
export { logErrorΔ } from './error-handler'; | ||
export { BettererErrorDetail, BettererErrorDetails } from './types'; |
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,46 @@ | ||
import { BettererError, isBettererError } from '@betterer/errors'; | ||
import { Box, Text } from 'ink'; | ||
import React, { FC } from 'react'; | ||
|
||
export type BettererTaskErrorProps = { | ||
error: Error | BettererError; | ||
}; | ||
|
||
let errorCount = 0; | ||
let detailCount = 0; | ||
|
||
export const BettererTaskError: FC<BettererTaskErrorProps> = function BettererTaskError({ error }) { | ||
let errors: Array<Error | BettererError> = []; | ||
let details: Array<string> = []; | ||
if (isBettererError(error)) { | ||
errors = error.details.filter((detail) => isError(detail)) as Array<Error | BettererError>; | ||
details = error.details.filter((detail) => !isError(detail)) as Array<string>; | ||
} | ||
return ( | ||
<> | ||
<Box flexDirection="column" paddingTop={1}> | ||
<Box> | ||
<Text color="redBright">Error: </Text> | ||
<Text>{error.message}</Text> | ||
</Box> | ||
{error.stack && ( | ||
<Box paddingLeft={2} paddingTop={1}> | ||
<Text>{error.stack}</Text> | ||
</Box> | ||
)} | ||
{details.map((detail) => ( | ||
<Box key={detailCount++} paddingTop={1}> | ||
<Text>{detail.trim()}</Text> | ||
</Box> | ||
))} | ||
</Box> | ||
{errors.map((error) => ( | ||
<BettererTaskError key={errorCount++} error={error} /> | ||
))} | ||
</> | ||
); | ||
}; | ||
|
||
function isError(value: unknown): value is Error | BettererError { | ||
return (value as Error).message != null && (value as Error).stack !== null; | ||
} |
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
Oops, something went wrong.