简体   繁体   English

Parse.com云代码(服务器)和iOS(客户端)的自定义错误

[英]Custom error with Parse.com Cloud Code (server) and iOS (client)

I have a Parse Cloud Code written in JavaScript, I have an code-based system so I have 3 different modes: 我有一个用JavaScript编写的Parse Cloud Code,我有一个基于代码的系统,所以我有3种不同的模式:

  • Code is found and have't been used before - SUCCESS 找到了代码,但之前从未使用过-SUCCESS
  • Code is found and have been used before - ERROR 找到并已使用过代码-错误
  • Code isn't found - ERROR 找不到代码-错误

Now, when the client (iOS) gets the success - everything works fine and the code is OK. 现在,当客户端(iOS)获得成功时-一切正常,代码正常。 But I want to determinate between the 2 errors I have and tell the user what's wrong (your code isn't available anymore/code not found), but the error code Parse sends is always 141 , so I don't know which message should I print to the user. 但是我想确定我遇到的两个错误,并告诉用户出了什么问题(您的代码不再可用/找不到代码),但是Parse发送的错误代码始终为141 ,所以我不知道应该显示哪条消息我打印给用户。

How can I change the error code of the error/another way to detect what error is it on client/server side? 如何更改错误的错误代码/另一种方法来检测客户端/服务器端的错误?

Thank you! 谢谢!

From https://parseplatform.github.io/docs/js/guide/#error-codes : https://parseplatform.github.io/docs/js/guide/#error-codes

ScriptFailed 141 Cloud Code script failed. ScriptFailed 141 Cloud Code脚本失败。 Usually points to a JavaScript error. 通常指向JavaScript错误。 Check error message for more details. 检查错误消息以获取更多详细信息。

FunctionNotFound 141 Cloud function not found. FunctionNotFound 141未找到云功能。 Check that the specified Cloud function is present in your Cloud Code script and has been deployed. 检查指定的Cloud功能是否存在于您的Cloud Code脚本中并已部署。

JobNotFound 141 Background job not found. JobNotFound 141找不到后台作业。 Check that the specified job is present in your Cloud Code script and has been deployed. 检查指定的作业是否存在于您的Cloud Code脚本中并已部署。

SuccessErrorNotCalled 141 success/error was not called. SuccessErrorNotCalled 141未调用成功/错误。 A cloud function will return once response.success() or response.error() is called. 一旦调用response.success()或response.error(),云函数将返回。 A background job will similarly finish execution once status.success() or status.error() is called. 一旦调用status.success()或status.error(),后台作业将同样完成执行。 If a function or job never reaches either of the success/error methods, this error will be returned. 如果函数或作业从未达到成功/错误方法中的任何一个,则将返回此错误。 This may happen when a function does not handle an error response correctly, preventing code execution from reaching the success() method call. 当函数无法正确处理错误响应,从而阻止代码执行到达success()方法调用时,可能会发生这种情况。

MultupleSuccessErrorCalls 141 Can't call success/error multiple times. MultupleSuccessErrorCalls 141无法多次调用成功/错误。 A cloud function will return once response.success() or response.error() is called. 一旦调用response.success()或response.error(),云函数将返回。 A background job will similarly finish execution once status.success() or status.error() is called. 一旦调用status.success()或status.error(),后台作业将同样完成执行。 If a function or job calls success() and/or error() more than once in a single execution path, this error will be returned. 如果函数或作业在单个执行路径中多次调用success()和/或error(),则将返回此错误。

So looking above, you could have a Javascript error occurring during the function's run. 因此,从上方看,您可能会在函数运行期间发生Javascript错误。 You could be spelling the function name wrong when calling. 调用时,您可能将函数名称拼写错误。 You could forget to call response.success() to properly close the function. 您可能会忘记调用response.success()来正确关闭该函数。 Or you could be calling response.success() / response.error() too many times, make sure that as you follow your code's logic, you only hit one of these for every path. 否则,您可能会多次调用response.success()/ response.error(),请确保在遵循代码逻辑时,您只为每条路径打了一个。

If you could post the code for your Cloud Code, we might be able to further help you. 如果您可以为您的云代码发布代码,我们也许可以为您提供进一步的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM