{"record":{"id":"a1d2b1a71ff33283","repo":"Semantic-Org/Semantic-UI","slug":"there-was-an-error-with-your-request","errorCode":null,"errorMessage":"There was an error with your request","messagePattern":"There was an error with your request","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/definitions/behaviors/api.js","lineNumber":1128,"sourceCode":"\n  // request finished without aborting\n  onComplete  : function(response, $module) {},\n\n  // failed JSON success test\n  onFailure   : function(response, $module) {},\n\n  // server error\n  onError     : function(errorMessage, $module) {},\n\n  // request aborted\n  onAbort     : function(errorMessage, $module) {},\n\n  successTest : false,\n\n  // errors\n  error : {\n    beforeSend        : 'The before send function has aborted the request',\n    error             : 'There was an error with your request',\n    exitConditions    : 'API Request Aborted. Exit conditions met',\n    JSONParse         : 'JSON could not be parsed during error handling',\n    legacyParameters  : 'You are using legacy API success callback names',\n    method            : 'The method you called is not defined',\n    missingAction     : 'API action used but no url was defined',\n    missingSerialize  : 'jquery-serialize-object is required to add form data to an existing data object',\n    missingURL        : 'No URL specified for api event',\n    noReturnedValue   : 'The beforeSend callback must return a settings object, beforeSend ignored.',\n    noStorage         : 'Caching responses locally requires session storage',\n    parseError        : 'There was an error parsing your request',\n    requiredParameter : 'Missing a required URL parameter: ',\n    statusMessage     : 'Server gave an error: ',\n    timeout           : 'Your request timed out'\n  },\n\n  regExp  : {\n    required : /\\{\\$*[A-z0-9]+\\}/g,\n    optional : /\\{\\/\\$*[A-z0-9]+\\}/g,","sourceCodeStart":1110,"sourceCodeEnd":1146,"githubUrl":"https://github.com/Semantic-Org/Semantic-UI/blob/597843ab84d565cccfd8fd7719416350ae73e734/src/definitions/behaviors/api.js#L1110-L1146","documentation":"This error is surfaced by Semantic UI's API module via the dynamic lookup settings.error[status] (api.js:705-706) when the jQuery AJAX request fails with a textStatus of 'error'. The errorFromRequest function checks if the response object has an 'error' property; if not, it falls back to settings.error['error'] which resolves to this message. It is the catch-all server error message.","triggerScenarios":"The server returns an HTTP error status (500, 404, etc.) during an API module request. The XHR fail handler (api.js:558-592) fires with status 'error', and errorFromRequest returns this message if the response body has no structured error field.","commonSituations":"Server-side exceptions, incorrect endpoint URLs producing 404s, CORS rejections producing network errors, or the server returning non-JSON error pages (HTML error pages). The error message is generic because it is the fallback when no specific server error detail is available.","solutions":["Check the browser Network tab for the actual HTTP status code and response body.","Ensure the server endpoint returns JSON with an 'error' field on failure, so the module can extract a specific message instead of this generic one.","Configure settings.successTest to differentiate between successful and failed responses within a 200 status.","Handle the error in settings.onError(errorMessage, $module, xhr) callback for user-facing feedback."],"exampleFix":"// before\n$('.api-element').api({\n  url: '/api/data',\n  // no error handling configured\n});\n\n// after\n$('.api-element').api({\n  url: '/api/data',\n  onError: function(errorMessage, $module, xhr) {\n    console.error('Server error:', xhr.status, errorMessage);\n    $module.closest('.ui.form').form('add errors', [errorMessage]);\n  }\n});","handlingStrategy":"try-catch","validationCode":"// Pre-validate the endpoint is reachable before the API call\n$.get('/api/health').done(function() {\n  $('.el').api('query');\n}).fail(function() {\n  console.error('Endpoint is not reachable.');\n});","typeGuard":"// Check if an XHR response indicates a server error\nfunction isServerError(xhr) {\n  return xhr && xhr.status >= 500;\n}","tryCatchPattern":"// Handle server errors in the API module's onError callback\n$('.el').api({\n  onError: function(errorMessage, $module, xhr) {\n    if (xhr.status >= 500) {\n      console.error('Server error:', xhr.status, errorMessage);\n      // Show user-friendly message\n    } else if (xhr.status === 404) {\n      console.error('Endpoint not found.');\n    }\n  }\n});","preventionTips":["Always configure settings.onError to handle server-side failures gracefully.","Ensure the server returns JSON with an error field on failure.","Monitor server health and endpoint availability in production."],"tags":["api","ajax","server-error","network","semantic-ui"],"backgroundTag":null,"analyzedSha":"597843ab84d565cccfd8fd7719416350ae73e734","analyzedAt":"2026-08-13T01:44:23.827Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}