Skip to content

Commit 03d4c5e

Browse files
authored
Small refactoring of getTypeInfo() (#1263)
1 parent d2ccec2 commit 03d4c5e

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

packages/build/src/error/cancel.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ const {
22
env: { DEPLOY_ID },
33
} = require('process')
44

5+
const { getErrorInfo } = require('./info')
56
const { getTypeInfo } = require('./type')
67

78
// Handle top-level build errors.
89
// Logging is done separately.
910
const maybeCancelBuild = async function(error, api) {
10-
const { shouldCancel } = getTypeInfo(error)
11+
const errorInfo = getErrorInfo(error)
12+
const { shouldCancel } = getTypeInfo(errorInfo)
1113
await cancelBuild(shouldCancel, api)
1214
}
1315

packages/build/src/error/monitor/report.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const reportBuildError = async function(error, errorMonitor) {
1717
return
1818
}
1919

20-
const { type, severity, title, group = title } = getTypeInfo(error)
2120
const errorInfo = getErrorInfo(error)
21+
const { type, severity, title, group = title } = getTypeInfo(errorInfo)
2222
const severityA = getSeverity(severity, errorInfo)
2323
const groupA = getGroup(group, errorInfo)
2424
const groupingHash = getGroupingHash(groupA, error, type)

packages/build/src/error/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ const parseError = function(error) {
3434
// Parse error instance into all the basic properties containing information
3535
const parseErrorInfo = function(error) {
3636
const { message, stack, ...errorProps } = normalizeError(error)
37-
const { title, isSuccess, stackType, getLocation, showErrorProps, rawStack } = getTypeInfo(errorProps)
3837
const errorInfo = getErrorInfo(errorProps)
38+
const { title, isSuccess, stackType, getLocation, showErrorProps, rawStack } = getTypeInfo(errorInfo)
3939
return {
4040
message,
4141
stack,

packages/build/src/error/type.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
const { getErrorInfo } = require('./info')
21
const { getBuildCommandLocation, getBuildFailLocation, getApiLocation } = require('./location')
32

43
// Retrieve error-type specific information
5-
const getTypeInfo = function(errorProps) {
6-
const { type } = getErrorInfo(errorProps)
4+
const getTypeInfo = function({ type }) {
75
const typeA = TYPES[type] === undefined ? DEFAULT_TYPE : type
86
return { type: typeA, ...TYPES[typeA] }
97
}

0 commit comments

Comments
 (0)