Fixed switch error code casting bug