# Error handling - insert error information into a table

**URL:** <https://www.singlestore.com/forum/t/error-handling-insert-error-information-into-a-table/5667>\
**Category:** Connectors and Pipelines\
**Created:** [September 28, 2022, 9:42am UTC](https://www.singlestore.com/forum/t/error-handling-insert-error-information-into-a-table/5667 "2022-09-28T09:42:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![maximg](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/m/ce7236/32.png) [@maximg](https://www.singlestore.com/forum/u/maximg)\
**Post date:** [September 28, 2022, 9:42am UTC](https://www.singlestore.com/forum/t/error-handling-insert-error-information-into-a-table/5667/1 "2022-09-28T09:42:24Z")

</div>

Hello,

We have a pipeline which inserts event data from kafka into several tables via execution of several stored procedures. We need to store failed batches errors into a table of errors. How can we extract the error from a failed procedure?

We want to do something like this:  
INSERT INTO [LearningErrorLog]  
(  
ErrorNumber  
,ErrorDescription  
,ErrorProcedure  
,ErrorState  
,ErrorSeverity  
,ErrorLine  
,ErrorTime  
)  
VALUES  
(  
ERROR\_NUMBER()  
,ERROR\_MESSAGE()  
,ERROR\_PROCEDURE()  
,ERROR\_STATE()  
,ERROR\_SEVERITY()  
,ERROR\_LINE()  
,GETDATE()  
);

I see the singlestore studio auto completes the function ERROR\_MESSAGE, but then says it’s not defined.

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![MariaSilverhardt](https://www.singlestore.com/forum/user_avatar/www.singlestore.com/mariasilverhardt/32/828_2.png) [@MariaSilverhardt](https://www.singlestore.com/forum/u/MariaSilverhardt)\
**Post date:** [September 28, 2022, 2:03pm UTC](https://www.singlestore.com/forum/t/error-handling-insert-error-information-into-a-table/5667/2 "2022-09-28T14:03:42Z")

</div>

Hi Maximg and welcome aboard! 👋  
We’d love to help with this issue.  
Are you running on the managed or self-hosted service and what version number?

---

<div class="post-metadata">

**Author:** ![maximg](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/m/ce7236/32.png) [@maximg](https://www.singlestore.com/forum/u/maximg)\
**Post date:** [September 29, 2022, 12:38pm UTC](https://www.singlestore.com/forum/t/error-handling-insert-error-information-into-a-table/5667/3 "2022-09-29T12:38:57Z")

</div>

Hi Maria,

I’m running in the self hosted currently.  
SingleStore DB Version: 7.8.14  
Studio Version: 4.0.7

Thanks

---

<div class="post-metadata">

**Author:** ![mkumar](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/m/e0b2c6/32.png) [@mkumar](https://www.singlestore.com/forum/u/mkumar)\
**Post date:** [September 30, 2022, 9:31pm UTC](https://www.singlestore.com/forum/t/error-handling-insert-error-information-into-a-table/5667/4 "2022-09-30T21:31:35Z")

</div>

hi @maximg did you check the pipeline error table that already captures the errors messages ?

> **[PIPELINES\_ERRORS · SingleStore Documentation](https://docs.singlestore.com/cloud/reference/information-schema-reference/pipelines/pipelines-errors/)**
>
> SingleStore is a modern relational database for cloud and on-premises that delivers immediate insights for modern applications and analytical systems. Book a demo or trial today!

Regards,  
Manish Kumar

---

<div class="post-metadata">

**Author:** ![maximg](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/m/ce7236/32.png) [@maximg](https://www.singlestore.com/forum/u/maximg)\
**Post date:** [October 2, 2022, 7:16am UTC](https://www.singlestore.com/forum/t/error-handling-insert-error-information-into-a-table/5667/5 "2022-10-02T07:16:35Z")

</div>

Hello @mkumar, no the insertion errors are not present there. what about my original question, getting last error information?

---

<div class="post-metadata">

**Author:** ![MariaSilverhardt](https://www.singlestore.com/forum/user_avatar/www.singlestore.com/mariasilverhardt/32/828_2.png) [@MariaSilverhardt](https://www.singlestore.com/forum/u/MariaSilverhardt)\
**Post date:** [October 17, 2022, 4:06pm UTC](https://www.singlestore.com/forum/t/error-handling-insert-error-information-into-a-table/5667/6 "2022-10-17T16:06:09Z")

</div>

Hi Maximg. Hope you find this helpful!

You may be able to get the information you need within the information\_schema and insert those values into another table as needed.

All errors from pipelines can be viewed on a table called

information\_schema.PIPELINE\_ERRORS

Here is a useful query to show all of the errors that occur in the pipeline:

SELECT DATABASE\_NAME, PIPELINE\_NAME, ERROR\_UNIX\_TIMESTAMP, BATCH\_ID, PARTITION, BATCH\_SOURCE\_PARTITION\_ID, ERROR\_KIND, ERROR\_CODE, ERROR\_MESSAGE, LOAD\_DATA\_LINE\_NUMBER, LOAD\_DATA\_LINE FROM information\_schema.PIPELINES\_ERRORS;

[Here](https://docs.singlestore.com/managed-service/en/load-data/about-loading-data-with-pipelines/pipeline-procedures/view-and-handle-pipeline-errors.html) is page that goes over how to handle pipeline errors.

If you can share what worked for you, others in the community may benefit from your postings. Cheers 🍻

---

<div class="post-metadata">

**Author:** ![maximg](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/m/ce7236/32.png) [@maximg](https://www.singlestore.com/forum/u/maximg)\
**Post date:** [October 19, 2022, 6:21am UTC](https://www.singlestore.com/forum/t/error-handling-insert-error-information-into-a-table/5667/7 "2022-10-19T06:21:17Z")

</div>

Hey @mkumar and @MariaSilverhardt,

Thanks for the support. The default pipeline errors are not enough. I want to add custom data that’s available during the error handling.

That’s why I’m asking about a way to extract the error data. To add it to the custom stuff.

Cheers, Maxim

---

<div class="post-metadata">

**Author:** ![deyler](https://www.singlestore.com/forum/letter_avatar_proxy/v4/letter/d/3ab097/32.png) [@deyler](https://www.singlestore.com/forum/u/deyler)\
**Post date:** [October 24, 2022, 6:54pm UTC](https://www.singlestore.com/forum/t/error-handling-insert-error-information-into-a-table/5667/8 "2022-10-24T18:54:27Z")

</div>

Hi Maxim, can you please paste your code and the ‘not defined’ error that you are getting back here? this will help us determine the issue you are having

> I see the singlestore studio auto completes the function ERROR\_MESSAGE, but then says it’s not defined.
