Skip to content

Commit 6bf5408

Browse files
beena352Ben Hillis
authored andcommitted
Localize port-conflict error
1 parent 1051ef2 commit 6bf5408

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

localization/strings/en-US/Resources.resw

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,10 @@ For privacy information about this product please visit https://aka.ms/privacy.<
21102110
<value>Volume '{}' is in use.</value>
21112111
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
21122112
</data>
2113+
<data name = "MessageWslcPortInUse" xml:space = "preserve" >
2114+
<value>Port {} is already in use, cannot start container {}</value>
2115+
<comment>{FixedPlaceholder="{}"}Command line arguments, file names and string inserts should not be translated</comment>
2116+
</data>
21132117
<data name = "MessageWslcBothDockerAndContainerFileFound" xml:space = "preserve" >
21142118
<value>Both Dockerfile and Containerfile found. Use -f to select the file to use</value>
21152119
<comment>{FixedPlaceholder="Dockerfile"}{FixedPlaceholder="Containerfile"}{FixedPlaceholder="-f"}Command line arguments, file names and string inserts should not be translated</comment>

src/windows/wslcsession/WSLCContainer.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,10 +1282,12 @@ std::unique_ptr<WSLCContainerImpl> WSLCContainerImpl::Open(
12821282
{
12831283
auto allocation = virtualMachine.TryAllocatePort(e.VmPort, e.Family, e.Protocol);
12841284

1285-
THROW_HR_WITH_USER_ERROR_IF(
1285+
THROW_HR_IF_MSG(
12861286
HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS),
1287-
std::format(L"Port {} is already in use, cannot open container {}", e.VmPort, dockerContainer.Id),
1288-
!allocation);
1287+
!allocation,
1288+
"Port %hu is in use, cannot open container %hs",
1289+
e.VmPort,
1290+
dockerContainer.Id.c_str());
12891291

12901292
inserted.VmMapping.AssignVmPort(allocation);
12911293
}
@@ -1451,7 +1453,8 @@ void WSLCContainerImpl::MapPorts()
14511453

14521454
THROW_HR_WITH_USER_ERROR_IF(
14531455
HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS),
1454-
std::format(L"Port {} is already in use, cannot start container {}", e.VmMapping.HostPort(), m_id),
1456+
wsl::shared::Localization::MessageWslcPortInUse(
1457+
std::format("{}:{}/{}", e.VmMapping.BindingAddressString(), e.VmMapping.HostPort(), e.ProtocolString()), m_id),
14551458
!allocatedPort);
14561459

14571460
e.VmMapping.AssignVmPort(allocatedPort);
@@ -1470,7 +1473,8 @@ void WSLCContainerImpl::MapPorts()
14701473
{
14711474
THROW_HR_WITH_USER_ERROR(
14721475
HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS),
1473-
std::format(L"Port {} is already in use, cannot start container {}", e.VmMapping.HostPort(), m_id));
1476+
wsl::shared::Localization::MessageWslcPortInUse(
1477+
std::format("{}:{}/{}", e.VmMapping.BindingAddressString(), e.VmMapping.HostPort(), e.ProtocolString()), m_id));
14741478
}
14751479
throw;
14761480
}

0 commit comments

Comments
 (0)