I suspect it's that my suitelet is returning JSON ...
# suitescript
k
I suspect it's that my suitelet is returning JSON but it looks like SuiteScript might be looking for an XML response...
b
you can try sharing your code to see if anyone can see weirdness
if you are really determined, you can try using the debugger and start adding breakpoints or setup pausing on errors
i personally would avoid it if possible, the javascript is chaotic
actually, this one is understandable, using the console's debugger should eventually get you where you want to go if you keep in mind what your response body is
k
I figured it out. My suitelet response was { error: 'string' }
I changed it to { message: string' } and it started working
apparently NetSuite doesn't like 'error' as a suitelet response JSON property
b
Copy code
function handleServerCallError(responseCode, responseBody, handleJson)
		{
			if (responseBody && responseBody.toLowerCase().indexOf('error')>=0)
			{
				if (isJson(responseBody))
				{
					if (handleJson && responseBody.indexOf('{"error"') >= 0)
					{
						var errorBody = JSON.parse(responseBody);
						throwServerCallError(errorBody.error.message, errorBody.error.code);
					}
				}
				else if (responseBody.indexOf('<onlineError>') >= 0)
				{
					var errorBody = apiBridge.nlapiStringToXML(responseBody);
					throwServerCallError(xmlHelpers.nlapiSelectValue(errorBody, '/onlineError/detail'), xmlHelpers.nlapiSelectValue(errorBody, '/onlineError/code'), xmlHelpers.nlapiSelectValue(errorBody, '/onlineError/id'));
				}
				else if (responseBody.indexOf('<error>') >= 0)
				{
					var errorBody = apiBridge.nlapiStringToXML(responseBody);
					throwServerCallError(xmlHelpers.nlapiSelectValue(errorBody, '/error/message'), xmlHelpers.nlapiSelectValue(errorBody, '/error/code'));
				}
				else if (responseBody.indexOf('error code:') >= 0 && responseBody.indexOf('error message:') >= 0 && responseCode != 200)
				{
					var errorBody = responseBody.split("\n");
					throwServerCallError(errorBody[1].substring("error message: ".length), errorBody[0].substring("error code: ".length));
				}
			}
			else if (responseCode != 200 && responseCode != 206 && responseCode != 500)
				throwServerCallError(responseBody, 'SERVER_RESPONSE_ERROR');
		}
basically yes
k
Ooooh, looks like I could use {error: {message: 'string'} } to throw it to catch for custom errors though