Throw error with status code on empty namespace

When throwing an error without status code it resolve in a 500 error.
Using an error with a status code resolve in more explicit errors.
This commit is contained in:
djexvr
2022-05-06 10:59:58 +02:00
parent ff5e55cfc7
commit 772827d076
+4 -1
View File
@@ -11,7 +11,10 @@ const dataStoreCache: IHashMapGeneric<DataStore> = {}
export default {
getDataStore: function (namespace: string) {
if (!namespace) {
throw new Error('NameSpace is empty')
throw ApiStatusCodes.createError(
ApiStatusCodes.STATUS_ERROR_NOT_AUTHORIZED,
'Empty namespace'
)
}
if (namespace !== CaptainConstants.rootNameSpace) {