# How to check ServerTravel error or check if the map exists

**URL:** <https://forums.unrealengine.com/t/how-to-check-servertravel-error-or-check-if-the-map-exists/823116>\
**Category:** C++\
**Tags:** unreal-engine, crash, CPP, question\
**Created:** [March 25, 2023, 10:57pm UTC](https://forums.unrealengine.com/t/how-to-check-servertravel-error-or-check-if-the-map-exists/823116 "2023-03-25T22:57:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultrafrog2012](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ultrafrog2012](https://forums.unrealengine.com/u/ultrafrog2012)\
**Post date:** [March 25, 2023, 10:57pm UTC](https://forums.unrealengine.com/t/how-to-check-servertravel-error-or-check-if-the-map-exists/823116/1 "2023-03-25T22:57:35Z")

</div>

I am using ServerTravel for switching maps in a single player game. ServerTravel returns true even if the map does not exist. The map name will be given by the user and I have to check if it exists first. How can I do that?

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [March 27, 2023, 9:18am UTC](https://forums.unrealengine.com/t/how-to-check-servertravel-error-or-check-if-the-map-exists/823116/2 "2023-03-27T09:18:46Z")

</div>

You can query asset registry to check existence of map without loading it.  
Something like this :

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/4/d/a4de525c91f4374fccae8cf5bf2cf24ad9e20bcb.png)

This is in case user provides only map name.  
If user provides full path (“/Game/Path/To/Level”), you can put that directly in PackageNames filter and don’t need to check with a loop.

---

<div class="post-metadata">

**Author:** ![ultrafrog2012](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ultrafrog2012](https://forums.unrealengine.com/u/ultrafrog2012)\
**Post date:** [May 28, 2023, 9:53pm UTC](https://forums.unrealengine.com/t/how-to-check-servertravel-error-or-check-if-the-map-exists/823116/3 "2023-05-28T21:53:16Z")

</div>

Thanks for your reply. Is there an equivalent method C++?

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [May 30, 2023, 8:02am UTC](https://forums.unrealengine.com/t/how-to-check-servertravel-error-or-check-if-the-map-exists/823116/4 "2023-05-30T08:02:23Z")

</div>

Of course, all blueprint methods use underlying C++ functions under the hood.

```cpp
#include "AssetRegistry/IAssetRegistry.h"

if (auto AssetRegistry = IAssetRegistry::Get())
{
    TArray<FAssetData> MapList;
    AssetRegistry->GetAssetsByClass(FTopLevelAssetPath(UWorld::StaticClass()->GetPathName()), MapList);
    //...
}

```

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [June 29, 2023, 8:02am UTC](https://forums.unrealengine.com/t/how-to-check-servertravel-error-or-check-if-the-map-exists/823116/5 "2023-06-29T08:02:31Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
