Skip to content

Commit d411141

Browse files
committed
Better exception message if no Manage permission when checking queue existence
1 parent c8b18de commit d411141

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

src/HangFire.Azure.ServiceBusQueue/ServiceBusManager.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,31 @@ private static void CreateQueueIfNotExists(string prefixedQueue, NamespaceManage
6666
return;
6767
}
6868

69-
Logger.InfoFormat("Checking if queue {0} exists", prefixedQueue);
70-
71-
if (namespaceManager.QueueExists(prefixedQueue))
69+
try
7270
{
73-
return;
74-
}
71+
Logger.InfoFormat("Checking if queue {0} exists", prefixedQueue);
7572

76-
Logger.InfoFormat("Creating new queue {0}", prefixedQueue);
73+
if (namespaceManager.QueueExists(prefixedQueue))
74+
{
75+
return;
76+
}
7777

78-
var description = new QueueDescription(prefixedQueue);
78+
Logger.InfoFormat("Creating new queue {0}", prefixedQueue);
7979

80-
if (options.Configure != null)
81-
{
82-
options.Configure(description);
83-
}
80+
var description = new QueueDescription(prefixedQueue);
81+
82+
if (options.Configure != null)
83+
{
84+
options.Configure(description);
85+
}
8486

85-
try
86-
{
8787
namespaceManager.CreateQueue(description);
8888
}
8989
catch (UnauthorizedAccessException ex)
9090
{
9191
var errorMessage = string.Format(
92-
"Queue {0} could not be created, likely due to missing the 'Manage' permission. " +
93-
"Either create the queue manually, or grant the Manage permission",
92+
"Queue '{0}' could not be checked / created, likely due to missing the 'Manage' permission. " +
93+
"You just either grant the 'Manage' permission, or setServiceBusQueueOptions.CheckAndCreateQueues to false",
9494
prefixedQueue);
9595

9696
throw new UnauthorizedAccessException(errorMessage, ex);

0 commit comments

Comments
 (0)