Custom block: How to know you're in an admin context? I've developed a custom block which relies on a taxonomy term ID being present in the URL, otherwise it throws a 404. 

I've placed this block in a panel page (ctools pages), but now when I try to edit the panel page, I get a 404 response, but only on the "Content" tab of the panel page variant.

What's the proper method for knowing you're on an admin page, or in the context of a panel edit, so that I can skip throwing a 404?
Looks like I just need to call path_is_admin

if (!path_is_admin(current_path())) {
  drupal_not_found();
  drupal_exit(); // This is needed if we call drupal_not_found() from hook_block_view()
}