0
디렉터리를 찾을 수 없을 때 예외를 throw하고 세부 정보를 표시하지 않아야합니다. powershell : 예외를 throw 할 때 메시지 만 표시하는 방법은 무엇입니까?
if(! (Test-Path -Path $destDir) )
{
throw "Directory $destDir not found!"
}
이 경우에 메시지가 코드에서 발생 하였다
and the details
를 나타낸다.
세부 정보없이 메시지 만 표시하는 방법이 있습니까? 당신의 catch 블록에
당신은'write-error'와'exit' /'break'를 사용할 수 있습니다. – Paul
@Paul write-error는 세부 사항을 보여줍니다. 내 해결책은'write-host "디렉토리가없는"-ForegroundColor Red'를 사용하는 것입니다. 감사! – boboes