Skip to content
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

Fixed error reporting #1908

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion backend/src/nodes/properties/inputs/numpy_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def enforce(self, value):

return value

def get_error_value(self, value: np.ndarray | Color) -> ErrorValue:
def get_error_value(self, value: np.ndarray | Color | None) -> ErrorValue:
if value is None:
return super().get_error_value(value)

def get_channels(channel: int) -> str:
if channel == 1:
return "Grayscale"
Expand Down
10 changes: 8 additions & 2 deletions backend/src/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ def run_node(node: NodeData, inputs: Iterable[object], node_id: NodeId) -> Outpu
# collect information to provide good error messages
input_dict: InputsDict = {}
for index, node_input in enumerate(node.inputs):
input_value = enforced_inputs[index]
input_dict[node_input.id] = node_input.get_error_value(input_value)
try:
input_value = enforced_inputs[index]
input_dict[node_input.id] = node_input.get_error_value(input_value)
except Exception as inner_e:
logger.error(
f"Error getting error value for input {node_input.label} (id {node_input.id})",
inner_e,
)

raise NodeExecutionError(node_id, node, str(e), input_dict) from e

Expand Down
2 changes: 1 addition & 1 deletion src/common/Backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type BackendErrorValue =
export interface BackendExceptionSource {
nodeId: string;
schemaId: SchemaId;
inputs: Record<InputId, BackendErrorValue>;
inputs: Partial<Record<InputId, BackendErrorValue>>;
}
export interface BackendExceptionResponse {
type: 'error';
Expand Down
4 changes: 3 additions & 1 deletion src/common/formatExecutionErrorMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export const formatExecutionErrorMessage = (
const inputValue = source.inputs[i.id];

let valueStr: string;
if (inputValue.type === 'formatted') {
if (inputValue === undefined) {
valueStr = '*unknown*';
} else if (inputValue.type === 'formatted') {
valueStr = inputValue.formatString;
} else if (inputValue.type === 'unknown') {
valueStr = `Value of type '${inputValue.typeModule}.${inputValue.typeName}'`;
Expand Down