Skip to content

I need help dealing with errors! #15

@rossanodr

Description

@rossanodr

What is the correct way to handle errors in the front end of this project?
I have some doubts about this because the StreamEvent in eventHandlerOne doesn't have typings for errors.

const eventHandlerOne = (
    streamEvent: StreamEvent,
    fields: EventHandlerFields
) => {
    try {
        const langGraphEvent: StreamEvent = streamEvent.data.chunk;
        console.log("langGraphEvent", langGraphEvent.error);

        if (!langGraphEvent) {
            return;
        }
        const { event, name, data } = langGraphEvent;
        if (event !== "on_chain_end") {
            return;
        }

    } catch (error) {
        console.log("error", error);
    }
};

In the example above, when I force an error, I get the result langGraphEvent Error
error TypeError: Cannot read properties of undefined (reading 'error').

However, the code presents typing errors:
Property 'error' does not exist on type 'StreamEvent'.ts(2339)

What is the ideal way to handle errors in langGraph cloud projects?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions