fix(xod-arduino, xod-client): add missing formatter for error about too many outputs

Closes #1545
This commit is contained in:
Evgeny Kochetkov
2018-11-23 19:23:38 +03:00
parent 7b28330cdc
commit f11156db5b
5 changed files with 22 additions and 9 deletions

View File

@@ -5,3 +5,5 @@ export {
getNodeIdsMap,
getRequireUrls,
} from './transpiler';
export { default as messages } from './messages';

View File

@@ -0,0 +1,10 @@
// Stanza creators.
// See `xod-func-tools` package Stanza type
export default {
TOO_MANY_OUTPUTS_FOR_NATIVE_NODE: ({ patchPath }) => ({
title: 'Too many outputs',
note: `C++ node ${patchPath} has more than 7 outputs. This is a limit for nodes implemented natively.`,
solution:
'Try to express the node as a XOD patch node composed of smaller C++ nodes or group the outputs into a new custom type.',
}),
};

View File

@@ -7,6 +7,7 @@ import {
maybeProp,
foldEither,
isAmong,
fail,
} from 'xod-func-tools';
import * as XP from 'xod-project';
import { def } from './types';
@@ -425,13 +426,9 @@ const checkForNativePatchesWithTooManyOutputs = def(
);
if (nodeWithTooManyOutputs) {
return Either.Left(
new Error(
`Native node ${
nodeWithTooManyOutputs.patchPath
} has more than 7 outputs`
)
);
return fail('TOO_MANY_OUTPUTS_FOR_NATIVE_NODE', {
patchPath: nodeWithTooManyOutputs.patchPath,
});
}
return Either.of(tProject);

View File

@@ -57,8 +57,10 @@ describe('xod-arduino transpiler', () => {
.then(
foldEither(
err => {
assert.include(err.message, '@/too-many-outputs');
assert.include(err.message, 'has more than 7 outputs');
assert.strictEqual(
err.message,
'TOO_MANY_OUTPUTS_FOR_NATIVE_NODE {"patchPath":"@/too-many-outputs"}'
);
},
() => assert(false, 'expecting Either.Left')
)

View File

@@ -1,10 +1,12 @@
import { composeErrorFormatters } from 'xod-func-tools';
import { messages as xpMessages } from 'xod-project';
import { messages as xardMessages } from 'xod-arduino';
import formatUnexpectedError from '../messages/formatUnexpectedError';
export default composeErrorFormatters([
xpMessages,
xardMessages,
{
UNEXPECTED_ERROR: formatUnexpectedError,
},