--- title: "Error Handling" slug: "error-handling" updated: 2025-12-10T01:45:44Z published: 2025-12-10T01:45:44Z canonical: "docs.xgen.ai/error-handling" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.xgen.ai/llms.txt > Use this file to discover all available pages before exploring further. # Error Handling All services return a standard [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)-based response, so the error handling is straightforward: ```javascript xg.recommend.getResultsById({elementId: ''}).then((result) => {  // success...  console.log('Result:', result); }).catch((error) => {  // error...  console.log('Error:', error); }); // OR if you are using the async/await syntax: try {  const result = await xg.recommend.getResultsById({ elementId: '' });  console.log('Result:', result); } catch (error) {  console.log('Error:', error); } ``` The response error is normalized and always returned as ResponseError object with the following public fields that you could use: ```typescript ResponseError {  url: string, // requested url  status: number, // response status code  response: { ... }, // the API JSON error response  isAbort: boolean, // is abort/cancellation error  originalError: Error|null, // the original non-normalized error } ```