Skip to content

Commit

Permalink
Fixed error reporting (#1908)
Browse files Browse the repository at this point in the history
* Fixed error reporting

* Error reporting should never fail
  • Loading branch information
RunDevelopment authored Jul 3, 2023
1 parent b316559 commit 286cb1c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
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

0 comments on commit 286cb1c

Please sign in to comment.