Skip to content

Commit

Permalink
Add "shim:" at the start of errors (#8)
Browse files Browse the repository at this point in the history
I've sometimes fiddled with scripts and shims for shortcuts and I really would've appreciated having this error tell me it's the shim telling me that I'm dumb and set up my path wrong, I hope this helps other fiddlers like me in the future
  • Loading branch information
couleurm committed Mar 26, 2023
1 parent ea09917 commit 36a6c52
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions shim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ std::tuple<std::wstring_p, std::wstring_p> GetShimInfo()

if (filenameSize >= MAX_PATH)
{
fprintf(stderr, "The filename of the program is too long to handle.\n");
fprintf(stderr, "Shim: The filename of the program is too long to handle.\n");
return {std::nullopt, std::nullopt};
}

Expand Down Expand Up @@ -167,23 +167,23 @@ std::tuple<std::unique_handle, std::unique_handle> MakeProcess(const std::wstrin

if (!ShellExecuteExW(&sei))
{
fprintf(stderr, "Unable to create elevated process: error %li.", GetLastError());
fprintf(stderr, "Shim: Unable to create elevated process: error %li.", GetLastError());
return {std::move(processHandle), std::move(threadHandle)};
}

processHandle.reset(sei.hProcess);
}
else
{
fprintf(stderr, "Could not create process with command '%ls'.\n", cmd.data());
fprintf(stderr, "Shim: Could not create process with command '%ls'.\n", cmd.data());
return {std::move(processHandle), std::move(threadHandle)};
}
}

// Ignore Ctrl-C and other signals
if (!SetConsoleCtrlHandler(CtrlHandler, TRUE))
{
fprintf(stderr, "Could not set control handler; Ctrl-C behavior may be invalid.\n");
fprintf(stderr, "Shim: Could not set control handler; Ctrl-C behavior may be invalid.\n");
}

return {std::move(processHandle), std::move(threadHandle)};
Expand Down Expand Up @@ -224,7 +224,7 @@ int wmain(int argc, wchar_t* argv[])

if (ret == 0)
{
fprintf(stderr, "Could not determine if target is a GUI app. Assuming console.\n");
fprintf(stderr, "Shim: Could not determine if target is a GUI app. Assuming console.\n");
}

const auto isWindowsApp = HIWORD(ret) != 0;
Expand Down

0 comments on commit 36a6c52

Please sign in to comment.