如何调试此问题?我找不到可追踪的信息。
我有以下传说:
export function* generateSoftwareLicenseCode({distributor, licenseType, duration}: GenerateSoftwareLicenseCodeAction) {
const username = getUsername();
const jwtToken = yield call(getJwtToken, username);
const link = new HttpLink({
uri: getGraphqlEndpointUrl,
headers: {
'x-api-key': getApiKey(),
'Authorization': jwtToken,
},
});
const client = new ApolloClient({
link: link,
cache: new InMemoryCache(),
});
try {
yield put(setStatusMessage('Generating license code...', 'info'));
yield client.mutate({
/* tslint:disable */
mutation: gql`
}
mutation licensemutation($distributor: String!, licenceType: String!, duration: String, userId: String) {
addLicenseCodeOneTimeUsage(distributor: $distributor, licenseType: $licenseType, duration: $duration, userId: $userId) {
code
}
}
`,
/* tslint:enable */
variables: {
userId: username,
distributor: distributor,
licenseType: licenseType,
duration: duration,
},
});
const doneMessage = 'License code successfully generated';
yield put(generateSoftwareLicenseCodeSucceeded(doneMessage));
} catch (error) {
const errors = error.networkError.result.errors;
yield put(generateSoftwareLicenseCodeFailed(filterErrorMessage(errors)));
}
}
export function* softwareLicenseCodesSagas() {
const generateSoftwareLicenseCodeWatcher = yield takeLatest(GENERATE_SOFTWARE_LICENSE_CODE_ACTION, generateSoftwareLicenseCode);
yield take(LOCATION_CHANGE);
yield put(clearMessages());
yield cancel(generateSoftwareLicenseCodeWatcher);
}
try块引发错误。 catch块中的error
未定义。
控制台显示uncaught at at at at b TypeError: Cannot read property 'result' of undefined
单步执行代码需要我一堆我不理解的库代码。
答案 0 :(得分:0)
如果在浏览器中正在执行此传奇,则可以像平常一样使用matrix[row + numberOfRows * column]
暂停执行并检查变量。如果它在服务器上,则debugger
可以正常工作。
就错误而言,最佳做法是在产生传奇中的已执行函数时始终使用console.log
redux-saga
方法。因此,您应该将其更改为:
call