public static function fromException(\Exception $ex) {
    if ($ex instanceof ApplicationException) {
      return $ex->getError();
    }
    if ($ex instanceof AuthorizationException) {
      return self::get(PERMISSION_DENIED);
    }
    return self::getGeneral($ex->getMessage());
  }