How to track errors in view I write some PHP code in my views, i.e. in contextual filters and the PHP area of view, but when something goes wrong, it becomes very difficult to find errors as line numbers thrown in error does not holds good. 

Which way can I trace it ,or is it not advisable to write PHP code in views directly?
Views is created in a very object oriented way, which is really great. What this means is that if the default Views behavior doesn't work for you, you can extend the classes that Views supply and alter only what you need to overwrite. I wrote a blog post about this focusing on filters, but the principle is the same for contexts, sorting ...

In views lingo a context is called an argument.