Livecode URL keyword - livecode

I have this code to access the URL content using URL keyword but I always got an error : An error occured: error. What have I missed?
on _common_parse_json pUrl
put "http://www.google.com" into pUrl
put URL pUrl into tResult
put the result into tError
if tError is empty then
set the text of field "result" to tResult
else
set the text of field "result" to "An error occurred:" && tError & ", parsing URL:"&&pUrl
end if
end _common_parse_json
P.S I'm using Livecode 7.1.4 community edition in Windows 8.1

Duh! that problem happens because the HTTP proxy is not empty. Clearing that out makes everything working.
I don't know why it was not empty, this is a fresh install.
I bumped into someone else thread and I forgot the link related to this concern.
Hope this helps somebody else.

Related

Basic Msi OpenPrinter API issue

I've tried everything I can think of but I'm unable to get OpenPrinter API to work in my BasicMsi
prototype BOOL SETUPAPI.OpenPrinterW(
WSTRING, //_In_ LPTSTR pPrinterName,
NUMBER,//_Out_ LPHANDLE phPrinter,
WPOINTER//_In_ LPPRINTER_DEFAULTS pDefault
);
try
OpenPrinterW(szDriverName, Printer, NULL);
catch
Err = GetLastError();
SprintfBox (INFORMATION, "L862Error","Error occured: %i\n\n%s\n\n%s", Err.Number, Err.Description, Err.LastDllError);
endcatch;
I always get a -2147219709 returned, I've also tried using OpenPrinterA and OpenPrinter but same error everytime.
Does anyone have any idea's as to what I may be doing wrong?
I suspect it's this error:
ERROR_PRINTER_DRIVER_ALREADY_INSTALLED
1795 (0x703)
The specified printer driver is already installed
I converted your error number into hex and it's 80040703 which is where I've gotten 703 from (8004 means it's an error in FACIILITY_ITF)
not sure if this helps... but it might get you started. I wonder if this is some sort of problem where msiexec can't see the printer so tries to install it.

Swift UIWebView Optional is nil

In the below example, infoScroller is a UIWebView and println(HTMLDescription) prints a lovely string of HTML. However, the attempt to loadHTMLString gets the runtime error: fatal error: Can't unwrap Optional.None
if let HTMLDescription = self.myData?.content? {
println(HTMLDescription)
infoScroller.loadHTMLString(HTMLDescription, baseURL: nil)
}
I've tried every combination of ! and ? in both the assignment and use of the string but I get this same error every time, though the variable never fails to print out perfectly to the console.
There is another value that I set using the same method and it works fine. Both are strings, but the other one is more simple in that HTMLDescription is multiline and the working one is not.
Edit: The discussion in the comments prompted me to check the infoScroller and it's description as printed in the console is: (#sil_weak UIWebView!) infoScroller =
I'm thinking that's the issue, but I'm not sure what it means or how to fix it.
Edit 2: This has to be the issue. println(infoScroller.description) yields the exact same error.
Got it! This question put me on the path. I was trying to load the content before the view was fully loaded. Moved loadHTMLString() into viewDidLoad(). Stupid simple.

Disable SqlError Reporting on 500 Error for a Production App

When there is a 500 error due to a bad query, Yesod displays the sql query on the page or parts of it. While this has been very helpful in development, I would like to avoid it in production. Is there a way to just display Internal Server Error and no other details?
Chances of having an error with sql is very low but it can still happen if a rogue user tries to come up with a badly formed input (the error message below is just a contrived example to illustrate the issue). There are DB constraints in place to avoid storing these bad inputs but the error message seems to be giving clues about the query, which I would like to avoid (I have seen larger parts of the query in some instances unlike the one below).
SqlError {sqlState = "42703", sqlExecStatus = FatalError,
sqlErrorMsg = "... duplicate key value (1480, 9, 3) violates unique constraint ...",
sqlErrorDetail = "", sqlErrorHint = ""}
I would like to avoid throwing a lot of try/catch-type blocks just to prevent these edge cases. A simple solution would be not display the sqlerror messages. Any thoughts on how I could do it? I am using Keter to deploy my app.
# Keter.yaml
exec: ../dist/build/MyApp/MyApp
args:
- production
host: www.example.com
Update: Here is a simple errorHandler to address this issue per Michael's answer.
-- Matching only InternalError. All other errors are
-- sent to the defaultErrorHandler as-is
newErrorHandler (InternalError msg) = do
$(logWarn) (append "Error Response: " $ pack (show (InternalError msg)))
defaultErrorHandler (InternalError "Custom message here")
newErrorHandler (errMsg) = defaultErrorHandler errMsg
Thanks!
You can override the default error handler in your Yesod typeclass using errorHandler. The default value is defaultErrorHandler, which displays the full value of the exception thrown. You can instead replace that with whatever information you want, conditional on the development value provided by the scaffolded site.
If you wanted to get a bit fancier, I'd recommend logging each exception thrown into your database and generating a random token, then displaying that token to the user on the error handler page. That way, the user can provide you that information so that you can better debug your application.
Using newErrorHandler did not work for me, so I instead solved it this way:
-- Foundation.hs
instance Yesod App where
errorHandler (InternalError e) = do
$(logWarn) e
fmap toTypedContent $ defaultLayout $ do
setTitle "Example site"
$(widgetFile "error")
errorHandler other = defaultErrorHandler other
And then create a custom error template in templates/error.hamlet…
$newline never
<h1>Internal Error
<p>Sorry, something has gone wrong.
You can add more error handers, pattern matching on the type of error. If you remove the other pattern, the compiler should tell you your pattern match is inexhaustive and provide some more patterns to match against.

XPages Custom Error Page - get error message and line

I'm trying to generate a custom error page for my xpages. I googled a lot of solutions and so far I get an error page telling me, that an error occured.
But I can't get the information what exactly happened (in this case the error is, that an "doc" has to be saved, but i named the variable "docs" just to get error).
All I do is:
var errObj = requestScope.error;
output = errObj.getCause().getErrorPropertyId();
output = errObj.getCause().getComponentId();
As soon as I try to call getExpressionText() I get an error 500.
How do I get the information, where the error happened (line number) and the variable that caused the error? - just like I do using the standard error page.
The error line and details are not easily accessible from requestScope.error. If you look at the source code for the latest release of Mark Leusink's Debug Toolbar, you'll see he's parsing the stack trace to get the details.
However, you can access all the relevant information using the underlying Java class for the SSJS exception - com.ibm.jscript.InterpretException using getErrorLine(). The getLocalizedMessage() method gets the error detail that usually starts "Script interpreter error". The getExpressionText() method retrieves the line that threw the error.
If you take a look at the XPages OpenLog Logger project I put on OpenNTF, that's what I use to log full details to OpenLog. http://www.openntf.org/Internal/home.nsf/project.xsp?action=openDocument&name=XPages%20OpenLog%20Logger
You can see the source code of the OpenLogPhaseListener which uses those methods here: https://github.com/paulswithers/openlogjava/blob/master/OpenLogJava/WebContent/WEB-INF/src/com/paulwithers/openLog/OpenLogPhaseListener.java
Even if you're not a Java expert, from use of SSJS the key parts should be understandable. Line 84 captures uncaught exceptions - when XPages routes to the default error page. That uses the methods I mentioned.
Lines 98 to 105 are the ones that log out all the details if you just use a catch block, passing OpenLogBean.addError(e, this) where e is the error object and this is the component the error occurs on. error.getError() in the Java code retrieves that error object. To get the typeahead in SSJS you'll need to use catch(e:com.ibm.jscript.InterpretException) I believe.
I haven't tested this, I've just working back from what I used for the project on OpenNTF.
Have a look at this XSnippet by Tony McGuckin: http://openntf.org/XSnippets.nsf/snippet.xsp?id=custom-error-page-cw-cause-and-stacktrace-information. It uses the following to output details on the error:
var output = requestScope.error.toString()+"\n\n";
if(requestScope.error instanceof com.ibm.xsp.exception.XSPExceptionInfo){
var codeSnippet = requestScope.error.getErrorText();
var control = requestScope.error.getErrorComponentId();
var cause = requestScope.error.getCause();
output += "In the control : " + control + "\n\n";
if(cause instanceof com.ibm.jscript.InterpretException){
var errorLine = cause.getErrorLine();
var errorColumn = cause.getErrorCol();
output += "At line " + errorLine;
output += ", column " + errorColumn + " of:\n";
}else{
output += "In the script:\n";
}
output += codeSnippet;
}
return output;
For now I've dealt with this problem by using the Debug Toolbar and the OpenLog Database.
If an error occurs the user only gets a custom error page (using the example of the Debug Toolbar) with the information, that something went wrong. So he does not have to bother with any other problems or even the Stack Trace. But at the same moment he gets the error page, the error is logged in our Log-Database with all informations needed (like line, exact error message etc.).
I've also implemented an "Report this problem" Link-Button to create a new E-Mail containing important information about the session the user is currently in.

sharepoint: Using a Content Editor Web Part this error occurred:"Cannot retrieve properties at this time."

I have a content editor web part. Whenever I edit the content and then click save, the following errors occurred:
"Cannot retrieve properties at this time."
"Cannot save your changes"
How do you fix this?
I tried googling it.. there are some similar cases but not exactly the same. I tried this link:
www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/MS-SharePoint/Q_21975446.html
and this one:
support.microsoft.com/kb/830342
and this one:
blogs.msdn.com/gyorgyh/archive/2009/03/04/troubleshooting-web-part-property-load-errors.aspx
I found the answer!! apparently using mozilla firefox it worked. Then I found out that there is a javascript error in IE, this javascript error doesnt happened in firefox. how ironic!
Are you doing anything to modify the URL in an HTTPModule? I ran into this problem on a publishing site where a module was hiding the "/pages" part of the URL. Modifying the CEWP via the page when accessed w/o the "/Pages" wasn't working, but with the "/Pages" it was.
Example:
Got error: http://www.tempura.org/webpartpage.aspx
Worked: http://www.tempuri.org/pages/webpartpage.aspx
I don't see how this is an answer -- "don't use IE".
In my case (and apparently many others) it has something to do with ISA + SharePoint + host headers. I will post the fix if I find one.
I have had problems with this before and have found recycling the Application Pool often corrects the problem.
Rodney
IE8 -->
Tools --> Compatiblity View Settings --> CHECK THIS : Display All Websites in ....
If you are editing a webpart page, make sure that it is checked out. Sometimes the document library the webpart pages are in will have a "force check out to edit" option and it will give you errors if the webpage itself isn't checked out.
I had this same error recently. In javascript, I had written some prototype overrides (see examples below) to add some custom functions to the string and array objects. Both of these overrides interferred with SharePoint's native JavaScript somehow in IE. I removed the references from the master page and this issue was FIXED. Currently trying to find a work-around so I can keep them because things like the string.format function is very nice to have...
//Trim
if (typeof String.prototype.trim !== 'function') {
String.prototype.trim = function(){
return this.replace(/^\s+|\s+$/g, '');
}
}
//Format
String.format = function() {
var s = arguments[0];
for (var i = 0; i < arguments.length - 1; i++) {
var reg = new RegExp("\\{" + i + "\\}", "gm");
s = s.replace(reg, arguments[i + 1]);
}
return s;
}
I also faced the same problem. Finally it worked for me using url /Pages/Contact-Us.aspx instead of clean URL. It worked only with IE browser. Don't know why this was happening but anyhow it worked with me.
Use IE browser
Use Pages in the URLinstead of clean URL.
to me,
compatibility mode in IE8, to work

Resources