Generic function that accepts both Actions and Func's as parameters I've created a generic try catch I can apply throughout my code so I'm not repeating myself.

private HttpResponseMessage TryCatch(Action action)
{
    return TryCatch(() =&gt; { action(); return "ActionToFunc"; });
}

private HttpResponseMessage TryCatch&lt;T&gt;(Func&lt;T&gt; func)
{
    try
    {
        var result = func();

        if (result.ToString() == "ActionToFunc")
        {
            return Request.CreateResponse(HttpStatusCode.OK);
        }

        return Request.CreateResponse(HttpStatusCode.OK, result);
    }
    catch (ArgumentNullException)
    {
        return Request.CreateResponse(HttpStatusCode.NotFound);
    }
    catch (Exception ex)
    {
        return Request.CreateResponse(HttpStatusCode.InternalServerError);
    }
}


I can call it using:

TryCatch(() =&gt; myFunction(parameter));


Is there a better way of doing achieving the same result?
Try to avoid using magic values. This one is a hack to avoid writing 2 methods.


private HttpResponseMessage TryCatch(Action action)
{
    return TryCatch(() =&gt; { action(); return "ActionToFunc"; });
}



You are better of splitting your methods. Dispatch error handling to its own method ResolveStatusCode to avoid boiler-plate error handling. In addition, perform argument checks. Since your method is private, I would favor Debug.Assert over ArgumentNullException.

    HttpResponseMessage TryCatch(Action operation)
    {
        try
        {
            Debug.Assert(operation != null, "invalid usage of API");
            operation();
            return Request.CreateResponse(HttpStatusCode.OK);
        }
        catch (Exception error)
        {
            return Request.CreateResponse(ResolveStatusCode(error));
        }
    }

    HttpResponseMessage TryCatch&lt;T&gt;(Func&lt;T&gt; func)
    {
        try
        {
            Debug.Assert(func != null, "invalid usage of API");
            var result = func();
            return Request.CreateResponse(HttpStatusCode.OK, result);
        }
        catch (Exception error)
        {
            return Request.CreateResponse(ResolveStatusCode(error));
        }
    }