Can Syntax Errors be handled?

SyntaxError is a perfectly ordinary built-in exception. It is not special in any way. Only the circumstances of when it’s (usually) thrown are a bit unusual. A syntax error means that the code featuring said error cannot be parsed. It doesn’t even begin to be a valid program, hence it cannot be executed. Therefore SyntaxError … Read more

Can Syntax Errors be handled?

SyntaxError is a perfectly ordinary built-in exception. It is not special in any way. Only the circumstances of when it’s (usually) thrown are a bit unusual. A syntax error means that the code featuring said error cannot be parsed. It doesn’t even begin to be a valid program, hence it cannot be executed. Therefore SyntaxError … Read more

PDO Exception Questions – How to Catch Them

You should look at the documentation. But If you dont find anything, you can add another catch : <?php try { $stmt = $db->prepare(“INSERT INTO tbl_user (id, name, password, question, answer) VALUES (NULL, :name, :password, :question, :answer)”); $stmt->bindValue(“:name”, $_POST[‘name’]); $stmt->bindValue(“:password”, $_POST[‘password’]); $stmt->bindValue(“:question”, $_POST[‘question’]); $stmt->bindValue(“:answer”, $_POST[‘answer’]); $stmt->execute(); echo “Successfully added the new user ” . $_POST[‘name’]; … Read more

Why use a JSF ExceptionHandlerFactory instead of redirection?

The particular example does only one useful thing: it saves the view ID as a request attribute so that you can use for example <h:link value=”Go back to previous page” outcome=”#{currentViewId}” /> But this is not tremendously useful as the raw request URI is already available by the <error-page>‘s default request attribute javax.servlet.error.request_uri. <h:outputLink value=”#{requestScope[‘javax.servlet.error.request_uri’]}”>Go … Read more

Throwing C++ exceptions across DLL boundaries

Throwing C++ exceptions across DLL boundaries is only possible when all modules use the same C++ runtime, in which case they share a heap as well. But this can be a maintenance burden, especially when libraries from multiple vendors are involved, so it is discouraged. If you want error-handling which is portable across multiple compilers/compiler … Read more

Close resource quietly using try-with-resources

I found this answered on the coin-dev mailing list: http://mail.openjdk.java.net/pipermail/coin-dev/2009-April/001503.html 5. Some failures of the close method can be safely ignored (e.g., closing a file that was open for read). Does the construct provide for this? No. While this functionality seems attractive, it is not clear that it’s worth the added complexity. As a practical … Read more