I'm trying to return an error from my AJAX page but no matter how I format it it's not seen as an error and the Promise continues unabated. The only way to actually trigger the catch is sending bad JSON (which is unhelpful) or a bad URL. This is not specific to Classic ASP but the app I'm trying to help fix uses that so that's where this example comes from:
Response.ContentType = "application/vnd.api+json"
Response.CharSet = "UTF-8"
Response.LCID = 1033
Response.Status "409 Conflict"
Response.Write "{ ""errors"": [ { ""status"": ""409"", ""source"": { ""pointer"": ""Error in new name"" }, ""title"": ""Name in use"", ""detail"": ""Filename already exists in this folder."" } ] }"
Response.End
I referred to https://jsonapi.org/examples/ to construct my sample error but it didn't change anything. How do I trigger the catch?
In response to the first comment this is the Fetch code:
fetch('/dofs.asp?action=rename&src=' + strSrc + '&dest=' + strDest)
.then(response => response.json())
.then(data => {
$('#pi' + citem + ' .pimage-title').attr('title', nname)
$('#pi' + citem + ' .pimage-title').html(nname)
})
.catch(error => {
console.log('error:' + error.message)
})
.finally(function() {
$('#pi' + citem + ' .pimage-title').css('color', 'unset')
$('#frename').attr('tabindex', '90');
$('#frename').css('display', 'none')
renaming = false
})