title: Returning From Within a Callee
body: <p>I have a client/server architecture rolled into the same executable project.  It also supports user-code access via script.  As such, in my code there are a lot of checks on critical methods to ensure the context in which they are being called is correct.  For example, I have a whole lot of the following:</p>
  
  <pre><code>public void Spawn(Actor2D actor)
  {
      if (!Game.Instance.SERVER)
      {
          Util.Log(LogManager.LogLevel.Error, "Spawning of actors is only allowed on the server.");
          return;
      }
      //Do stuff.
  }
  </code></pre>
  
  <p>I would like to cut down on this duplication of code.  <strong>Does there exist something in C# what would give me the functionality to do something like</strong>:</p>
  
  <pre><code>public void Spawn(Actor2D actor)
  {
     AssertServer("Spawning of actors is only allowed on the server.");
     //Do stuff.
  }
  </code></pre>
  
  <p>Even a generic message like "[MethodNameOfPreviousCallOnStack] can only be called on the server." would be acceptable.  But it would have to also return from the caller as well (in this case <code>Spawn()</code>), as to function like an abort.  Similar to an <code>assert</code>, but instead of generating an exception just returns.  Thanks!</p>