Explanation
DEXTUploadX5 All errors that occur at the time of operation are passed to the onDX5Error callback function, except for errors that occur during component creation.
/**
* All error and warning messages passed through the component or inside can be retrieved via the onDX5Error callback function.
* @param {string} id The ID of the component for which the error or warning occurred.
* @param {string} code error code
* @param {string} msg error message
*/
function onDX5Error(id, code, msg) {
alert(id + " => " + code + "\n" + msg);
}
If the onDX5Error function is not in the page, there is no way to check for errors.
In addition to the onDX5Error function, DEXTUploadX5 has no logging facility to record errors separately.
The onDX5Error function is not responsible for any grammatical or logical script errors that occur during development.
If an error occurs in the server after uploading the file, it is judged that the uploading has failed. HTTP will return an HTTP status code of 200 if the code completes successfully on the server when doing a GET/POST request (as does file upload). When DEXTUploadX5 receives the 200 code value from the server, it notices that the file upload is completed and calls the onDX5UploadCompleted callback function.
On the other hand, if the server receives an HTTP status code such as 400, 403, 404, or 500, it assumes that an error has occurred, stops the further operation and calls the onDX5Error callback function. Therefore, server-side code should not ignore an error and take action to ensure that 500 errors are delivered when an exception occurs. If the server holds an error like a try - catch statement and does not pass an error, the server will return a value of 200, so DEXTUploadX5 will misunderstand that the upload was successful. In addition, when an error occurs in the server, the error page is often sent to the client after decorating it in a pretty format. However, if the status code of response page is 200, the DEXTUploadX5 judges that the upload has been completed successfully.
In the example, the server side is configured to generate a 404 error when the submit button is pressed.
function onDX5Created(id) {
var dx = dx5.get(id);
// The upload path does not actually exist.
// Therefore, clicking on the submit button will result in a 404 error on the server.
dx.setUploadURL(dx5.canonicalize("../service/not-existed-service.do"));
}
Example