Parse FileSaveError Code 130 - swift

this is my first ever question so please let me know if I can improve anything in the future.
I am self-learning Swift and Parse. When I tried to save an image to Parse, it gave me the error as can be seen in the picture.
Error message picture
The error message in the picture is as following:
Parse::FileSaveError (Code: 130, Version: 1.11.0)
Can someone please help me with this? I'm not familiar with Swift or Parse so I don't know if they have any certain behaviours.
Many thanks

The definition for the error code you are receiving is:
"Error code indicating that a unique field was given a value that is already taken."
As your code appears to be valid, the issue is most likely in the Parse database itself. Go into Parse core and remove the "Post" class you have created and try running the code again.
It is worth noting that it can help to use print(error) to print the actual error out rather than just a string.

Related

mysqli_query($conn, $sql) On adding this, giving an error of 500 INTERNAL SERVER ERROR, No detailed error shown [duplicate]

In my local/development environment, the MySQLi query is performing OK. However, when I upload it on my web host environment, I get this error:
Fatal error: Call to a member function bind_param() on a non-object in...
Here is the code:
global $mysqli;
$stmt = $mysqli->prepare("SELECT id, description FROM tbl_page_answer_category WHERE cur_own_id = ?");
$stmt->bind_param('i', $cur_id);
$stmt->execute();
$stmt->bind_result($uid, $desc);
To check my query, I tried to execute the query via control panel phpMyAdmin and the result is OK.
TL;DR
Always have mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); in your mysqli connection code and always check the PHP errors.
Always replace every PHP variable in the SQL query with a question mark, and execute the query using prepared statement. It will help to avoid syntax errors of all sorts.
Explanation
Sometimes your MySQLi code produces an error like mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given..., Call to a member function bind_param()... or similar. Or even without any error, but the query doesn't work all the same. It means that your query failed to execute.
Every time a query fails, MySQL has an error message that explains the reason. In the older PHP versions such errors weren't transferred to PHP, and all you'd get is a cryptic error message mentioned above. Hence it is very important to configure PHP and MySQLi to report MySQL errors to you. And once you get the error message, fixing it will be a piece of cake.
How to get the error message in MySQLi
First of all, always have this line before MySQLi connect in all your environments:
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
After that, all MySQL errors will be transferred into PHP exceptions. An uncaught exception, in turn, makes a PHP fatal error. Thus, in case of a MySQL error, you'll get a conventional PHP error. That will instantly make you aware of the error cause. And the stack trace will lead you to the exact spot where the error occurred.
How to get the error message from PHP
Here is a gist of my article on PHP error reporting:
Reporting errors on a development and live servers must be different. On the development server it is convenient to have errors shown on-screen, but on a live server error messages must be logged instead, so you could find them in the error log later.
Therefore, you must set corresponding configuration options to the following values:
On a development server
error_reporting should be set to E_ALL value;
log_errors should be set to 1 (it is convenient to have logs on a development PC too)
display_errors should be set to 1
On a production server
error_reporting should be set to E_ALL value;
log_errors should be set to 1
display_errors should be set to 0
After that, when MySQL query fails, you will get a PHP error that explains the reason. On a live server, in order to get the error message, you'll have to check the error log.
In case of AJAX call, on a dev server open DevTools (F12), then Network tab. Then initiate the request which result you want to see, and it will appear in the Network tab. Click on it and then the Response tab. There you will see the exact output. On a live server check the error log.
How to actually use it
Just remove any code that checks for the error manually, all those or die(), if ($result), try..catch and such. Simply write your database interaction code right away:
$stmt = $this->con->prepare("INSERT INTO table(name, quantity) VALUES (?,?)");
$stmt->bind_param("si", $name, $quantity);
$stmt->execute();
Again, without any conditions around. If an error occurs, it will be treated like any other error in your code. For example, on a development PC it will just appear on-screen, while on a live site it will be logged for the programmer, whereas for the user's convenience you could use an error handler (but that's a different story which is off topic for MySQLi, but you may read about it in the article linked above).
What to do with the error message you get
First of all you have to locate the problem query. The error message contains the file name and the line number of the exact spot where the error occurred. For the simple code that's enough, but if your code is using functions or classes you may need to follow the stack trace to locate the problem query.
After getting the error message, you have to read and comprehend it. It sounds too obvious if not condescending, but learners often overlook the fact that the error message is not just an alarm signal, but it actually contains a detailed explanation of the problem. And all you need is to read the error message and fix the issue.
Say, if it says that a particular table doesn't exist, you have to check spelling, typos, and letter case. Also you have to make sure that your PHP script connects to a correct database
Or, if it says there is an error in the SQL syntax, then you have to examine your SQL. And the problem spot is right before the query part cited in the error message.
If you don't understand the error message, try to google it. And when browsing the results, stick to answers that explain the error rather than bluntly give the solution. A solution may not work in your particular case, but the explanation will help you to understand the problem and make you able to fix the issue by yourself.
You have to also trust the error message. If it says that number of tokens doesn't match the number of bound variables then it is so. The same goes for the absent tables or columns. Given the choice, whether it's your own mistake or the error message is wrong, always stick to the former. Again it sounds condescending, but hundreds of questions on this very site prove this advise extremely useful.
A list of things you should never ever do in regard of error reporting
Never use an error suppression operator (#)! It makes a programmer unable read the error message and therefore unable to fix the error
Do not use die() or echo or any other function to print the error message on the screen unconditionally. PHP can report errors by itself and do it the right way depends on the environment - so just leave it for PHP.
Do not add a condition to test the query result manually (like if($result)). With error exceptions enabled such condition will just be useless.
Do not use the try..catch operator for echoing the error message. This operator should be used to perform some error handling, like a transaction rollback. But never use it just to report errors - as we learned above, PHP can already do it, the right way.
P.S.
Sometimes there is no error, but no results either. Then it means, there is no data in the database to match your criteria. In this case you have to admit this fact, even if you can swear the data and the criteria are all right. They are not. You have to check them again.
I've got an article that can help in this matter, How to debug database interactions. Although it is written for PDO, the principle is the same. Just follow those instructions step by step and either have your problem solved or have an answerable question for Stack Overflow.

Custom Error Messages in CITRUS Test Results

I want to use my custom error messages in my citrus test results.
Example:
Original Error Message: java.io.FileNotFoundException: D:\expectedOutput\Smaple.xml (The system cannot find the file specified).
Custom Message: Hey The File was not found in your directory Please check. (Need to print like this in my test results failure message).
Please check the image hereenter image description here
You can not change this message in particular as this is coming from the thrown Java exception. You could implement your own TestReporter and/or TestListener though to translate the error into something matching your needs.
Something like: https://citrusframework.org/samples/reporting/

Expected response code 200, got 400. Unable to convert document

In the last 2 weeks or so, I've suddenly started getting reports of users getting an error in our application saying "Expected response code 200, got 400. Unable to convert document." This is code that has been in place for years without any issue. We are using Zend Framework (GData) in conjunction with Google Docs (AuthSub).
We are logging the issue to a text file when it happens. When it gets logged, the user often tries multiple times (sometimes separated by a few seconds, other times separated by longer times) and it continues to fail. The code in question just creates a new Google document in the user's account and gives it a title (no body content).
Originally, I used this code:
// Create new document
$data = new Zend_Gdata_Docs_DocumentListEntry();
$data->setCategory(
array(new Zend_Gdata_App_Extension_Category(
"http://schemas.google.com/docs/2007#document",
"http://schemas.google.com/g/2005#kind"
)));
$data->setTitle(new Zend_Gdata_App_Extension_Title($title, null));
// Add document to your list
$test = $sharedocs->insertDocument($data, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
To experiment and see if there was an issue with that particular function, I tried creating a blank word doc and changing the code to:
$test = $sharedocs->uploadFile('/mypath/empty.doc', $title, null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
However, I'm still seeing the "Unable to convert document" errors. They are relatively infrequent, and I am not able to reproduce the issue on my own computers here. The $title variable does not contain anything unusual (special characters, etc.).
This code was all working fine before -- is there a known issue with the Google Docs API right now? What else can I try?
NOTE: Please see my follow-up comments below, where I have identified the reproducible scenario in which this error occurs.
I had exactly the same problem, but I noticed that I could use the api to save a presentation if not a document... so, it is a terrible hack, but I try to save the document (works if the account has already been accessed)... if that fails, I save and delete a presentation and retry to save the document, which then works. Horrible, horrible, horrible hack

Error Domain=NSXMLParserErrorDomain Code=64 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 64.)"

What deos the error 64 in NSXMLParserDomain Code=64 mean? I am using an NSXMLParser to parse my XML data. But i am getting the above mentioned error. Can someone please help me on this?
I found it out. The error comes when the XMl contains errors at the start up. U can validate the XMl using w3schools here http://www.w3schools.com/xml/xml_validator.asp[How to validate an XML]1
Its also happens if the XML contains some extra line before the xml tag starts.

xmlCtxtGetLastError - Iphone

I have been programming with NSXMLParser for quite a while and lately, I came out with this error. The strangiest thing is that it only happens in debug mode. Once I load the App in Simulator and run it from Simulator (without Xcode involved), it runs fine.
The code is very straight foward, it is a simple XML parsing whose contents were loaded from the web in a separated thread.
Does anybody have alredy encoutered that error??
Thanks in advance.
EDIT:
In time I realized that this error occur when you have a bad formated XML Document. In my case, I was extracting some of the contents of an HTML Page and parsing the resulting string, but this string was not allways well formed. A little modification an voilá...
Ensure that your documents are well formed when parsing or you may have the same mistake...
PS: The parser error method did not catch this error.
In time I realized that this error occur when you have a bad formated XML Document. In my case, I was extracting some of the contents of an HTML Page and parsing the resulting string, but this string was not allways well formed. A little modification an voilá...
Ensure that your documents are well formed when parsing or you may have the same mistake... PS: The parser error method did not catch this error.