Alright dudes... I have a problem that is looking for an answer more specific than the seemingly obvious solution.
I have a block of code that I want to execute directly after a url is known to be valid. What I mean by 'valid' is that the program has checked to see if that filepath actually exists. This could be accomplished by a COMPLETE listener, because after all, a loader couldn't finish loading its content if the referenced file didn't exist, but I want it to happen before any of the bytes begin to get sucked in. I have also tried the HTTPS_STATUS event, with a conditional saying "if the status is this [some non-error status number], then run this block of code." This would have worked great, except that different environments produce different network codes, and some even can't distinguish between errors and non-errors, just returning 0's no matter what. Because of this, I can't write a conditional that works no matter what browser....
So, anyone got any ideas?!?!?!?!
If this doesn't work post your code.
myUrlLoader.addEventListener(Event.OPEN, openHandler);
//Dispatched when the download operation commences following a call to the URLLoader.load() method.
Related
Recently I read a query about "What does console.log do" and I read an answer, tried using it and found that despite the answer stating that it outputs to the console in googles browser, I just tried it and I get no output.
I did try this code:
function put(p){
if ( window.console && window.console.log ) {
console.log(p); // console is available
}else{
alert(p);
}
}
BUT... I get neither console output or alert and furthermore .log is a Math property, what gives with that?
Make sure that in the Developer Tools the Filter in the console section is set to All or Logs...
I had a similar experience where I couldn't see any of my console.log output and it was because the console was set to filter on Errors only... All the log entries were there - they just weren't visible.
Bonus marks: you can also Ctrl + Click to select multiple filters (Errors + Logs for example).
Press F12 and look at in Developer Tools: Console. I tried your code just now, works fine for me -- Chrome version 30.0.
Since you're after console logging, not mathematical logarithms, perhaps you could stop going on about there being similarly-named function in the Math object. It's not relevant here whatsoever.
You're also coming across just a little shouty. console.log() works fine, and your question didn't indicate that you knew where to look. This is totally your problem, but I'm trying to help you. I can obviously only go on the information you provide, and I can't say your initial question was written very clearly.
It appears, since the snippet of code you posted works here absolutely fine, that your calling code & containing (which you haven't posted) would be the cause of the problem. You should debug these, to find out what's going wrong.
Do you know how to use the Chrome debugger? Are there any error messages showing in Chrome or on the console?
Test it on a simple page if necessary, to rule out other errors in the page/ or surrounding context breaking it. One common mistakes is declare functions in a jQuery ready handler or similar, and then try & access them globally. Make sure your logging function is actually global (outside any other function(){} or object {} blocks).
Lastly, it's good to have a logging function for portability (I have one myself) but put() is not a good name for it. Naming it consoleLog() or log() would be better.
Had the same issue .
Make sure your using de right path when you try import thing's .
Example whit my issue :
Wrong path ----> ** import normalizedData from 'normalizr'; **
Right path ---> ** import normalizedData from '../schemas/index.js'; **
I had also faced the same problem. Make sure you apply no filter in the console. It worked for me.
I am trying to show an array of TPANELs to be used by the user as a menu system. It all seems to work fine but here's the issue.
If I always click the first item (i.e., TPanel), then I can click the other items as well. But if I start by clicking the last item, it shows the error "Access violation" AFTER it has shown the items.
The strange thing is that despite the error, the system does not crash. So I enabled the debugger (DBG). Now it crashes with the error as follows:
And once the program stops, I see the following in the history window of the debugger.
Please note that I'm not keen right now in fixing this error as I think this is trivial. But I want to be able to capture the error as it occurs and do something (for now I want to ignore it).
I'm using Ubuntu 12.04 with Lazarus 1.0.10.
The method I use must work on WINDOWS and LINUX.
Thanks in advance for any help!
Generally, to catch an exception, there's the try..except block. For sure your goal is not to catch an exception and ignore it, but find it in your code and fix the source of the problem. Of course, there might be situations, where the risk of an exception is high or expected so the use of a try..except block is necessary there. Those blocks of code we are enclosing this way:
procedure TForm1.Button1Click(Sender: TObject);
var
NotExistingPanel: TPanel;
begin
try
NotExistingPanel.Caption := ''; // <- this will raise an access violation
except
on E: Exception do
ShowMessage('An exception was raised: ' + E.Message);
end;
end;
Your problem will be somewhere in an OnMouseUp event handler of some of your controls and it's been caused by accessing the memory, that the CPU cannot physically address. This might happen e.g. when you access an object which has not been created, or already released, but there are also many different ways how to cause an access violation.
First, a big thank you to TLama for all the explanations and directions. I have to accept his answer as I've built mine based on that. I'm only posting this as an answer so that another person who's a beginner to Lazarus may find this useful. I'm not in anyway suggesting that this is the best thing to do, but this is what I want to do for now. That is, when a certain exception occurs, I want to trap it and deal with it.
Given that,
I am dynamically creating a set of TPanels to look like buttons
Each TPanel has assigned to it a mouseclick event
Let's assume that there are 10 such 'buttons' (actually TPanels).
The problem:
When I first click on the first button, I can then click on another one (eg: the 5th). But if I first click the 5th or anything else other than the first, the program throws the 'Access violation' error. Note however, that the program doe not crash despite the ugly warning about data corruption and stuff. So the user can simply click ok and continue. Strangely then, with subsequent clicks, this problem reduces! I know that's funny.
Now, as explained by TLama, the error occurs when the mouse is being released AFTER clicking a button.
But here's my problem... I don't have a mouseup event. That's part of Pascal.
So now, I want to ignore the mouseup event (at least for now). There MUST be a better way.
But there's another issue. I cannot ignore what I don't have! And I don't have a mouseup event. So I finally decided to capture this error at application level like this:
On the main form, I put this code:
procedure TfrmMainForm.CatchErr(Sender: TObject; e:exception);
begin
if e.Message <> 'Access violation' then ShowMessage('MOL: ' + e.Message);
end;
And then on form create, I put this:
Application.OnException:=#CatchErr;
And (for now) I can circumvent this issue.
Once again, as TLama has indicated, this is not good advice. Nonetheless, it is what I wanted to do.
Also what makes it harder is that the error is occuring in mouseup, which is in control.inc. And this is not my file. Rather it's part of Lazarus. I think it would be better if we had a way of telling Lazarus to delete that event for the TPanels in the code. I think it involves re-writing a derived class for it and I don't see how that's any good for me right now :)
Thanks again TLama!
Using Scriptella ETL, i recently came to know about the onerror tag. It is working fine,but I want to make a generic code which inserts the code and the message into the database whenever any error occurs.
I am using it like this:
<onerror codes="42604,42617,42000,1366" >
INSERT INTO demo_travel.test_log(Time_Now, ErrorName) values ( sysdate(),'eeuhue');
</onerror>
Which is working, but I want something like this:
<onerror >
INSERT INTO demo_travel.test_log(Time_Now, ErrorName,ErrorMSG) values ( sysdate(),Error.code, error.msg);
</onerror>
Unfortunately there is no easy way to achieve that. onerror was based on the assumption that a developer knows an error he is dealing with. But I do agree this has to be improved. The problem was partially addressed in a Feature request: Allow different connection-id in onerror element.
So for 1.1 or earlier versions, this is not possible. For a current development snapshot of 1.2, this information can be inferred from the "error" variable as explained in the ticket. I've also created a subticket to expose additional properties of the error.
I have installed the sfErrorNotifierPlugin. When both options reportErrors/reportPHPErrors reportPHPWarnings/reportWarnings are set to false, everything is ok. But I want to catch PHP exceptions and warnings to receive E-mails, but then all my tasks fail, including clear-cache. After few hours of tests I'm 100% sure that the problem is with set_exception_handler/set_error_handler.
There's a similar question:
sfErrorNotifierPlugin on symfony task but the author there is having problems with a custom task. In my case, even built-in tasks fail.
I haven't used sfErrorNotifierPlugin, but I have run into 'The “default” context does not exist.' messages before. It happens when a call is made to sfContext::getInstance() and the context simply doesn't exist. I've had this happen a lot from within custom tasks. One solution is to add sfContext::createInstance() before the call to sfContext::getInstance(). This will ensure that a context exists.
There's an interesting blog post on 'Why sfContext::getInstance() is bad' that goes into more detail - http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/
Well, the problem could not be solved this way, unfortunately. Using sfErrorNotifierPlugin, I have enabled reporting PHP warning/errors (apart from symfony exceptions) and this resulted in huge problems, e.g. built-in tasks such as clear-cache failed.
The solution I chose was to load the plugin only in non-task mode (project configuration class):
public function setup()
{
$this->enableAllPluginsExcept('sfPropelPlugin');
if ('cli' == php_sapi_name()) $this->disablePlugins('sfErrorNotifierPlugin');
}
WHen a task is executed, everything works normally. When an app is fired from the browser, emails are sent when exception/warning occurs (maybe someone will find it useful).
Arms has explained the problem correctly. But usually context does not exist when executing backend/maintenance tasks on the console. And it is easier if you handle the condition yourself.
Check, if you really need the context?
If you do, what exactly do you need it for?
Sometimes you only want a user to populate a created_by field. You can work around by hard-coding a user ID.
If you want to do something more integrated, create a page (which will have a context) and trigger the task from there.
you can test the existance of the instance before doing something inside a class. Like:
if(sfContext::hasInstance())
$this->microsite_id = sfContext::getInstance()->getUser()->getAttribute('active_microsite');
I've been experiencing the same problem using the plugin sfErrorNotifier.
In my specific case, I noticed a warning was raised:
Warning: ob_start(): function '' not found or invalid function name in /var/www/ncsoft_qa/lib/vendor/symfony/lib/config/sfApplicationConfiguration.class.php on line 155
Notice: ob_start(): failed to create buffer in /var/www/ncsoft_qa/lib/vendor/symfony/lib/config/sfApplicationConfiguration.class.php on line 155
So, checking the file: sfApplicationConfiguration.class.php class, line 155,
I've replaced the ' ' for a null, then the warnings disappears, and also the error!
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : ''); bad
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : null); good
I am trying the post an invoice to SAP using the F-47 transaction and using SHDB to record the transaction and learn how it works. I see there that sometimes BU and ZK BDC OK codes are used. I would like to understand the difference between them, but could not find any official documentation. Please, explain the difference between the two?
I found the meaning of some of the status codes. I post it here, so I can remember:
/00. Enter
/AB Go to overview
=ZK Go to additional information
=ENTE Enter (don't know exactly what is difference between /00)
=PI select cursor location
=STER Go to taxes
=DELZ delete cursor
=GO continue
=BU post (save)
/EEND end processing
=Yes select "yes" from message box
=BP park (save)
=ENTR Enter (don't know exactly what is difference between =ENTE or /00)
=AE save when changing document
=BK change document header (parking or posting parked document)
=P+ next page
=BL delete parked document
A BDC_OKCODE indicates which action is (will) be executed on a screen (things like save, back, exit etc). The BU code is used for a SAVE function (like in MM01 transaction). Sorry but I cannot recall to which function ZK maps to. Obviously their difference lies in the fact that they map to different functions. You can still find out which function each button utilizes by using System->Status->GUI status.
By the way, BTCI transactions are not fully robust- minor changes in GUI flow let your program break. Error handling / analysis is tedious.... DId you have a look to posting methods more preferably? E.g. like BAPI_* function modules? With the help of LSMW you can browse for different input methods and use them later standalone. Or you can use transaction BAPI directly.