1. Create new exceptions for each class of error in your libs.
2. Just use stuff from the exceptions module most of the time and create new exceptions when using a standard one is really inappropriate.
My colleagues strongly prefer #1, and go around making dozens of FilePermissionsError or ValueErrorBecauseFuckYou. They are also OOP and Patterns nuts. I am not a very happy man because I have to import their horde of bullshit exceptions into my modules instead of just using standard classes.
>>42
That won't work when you change the directory. Use >>43 instead.
Also, be sure to put: cat <<EOF
$(uname -o) [Version $(uname -r)]
Copyright (c) $(date +%Y) Richard Matthew Stallman. All freedoms respected.
EOF
at the end of your .bashrc
Result: GNU/Linux [Version 3.4.2-4.fc17.x86_64]
Copyright (c) 2012 Richard Matthew Stallman. All freedoms respected.
C:\home\chris>
Name:
Anonymous2012-06-22 8:22
>>43 C:\home\faggot>dir /p
dir: cannot access /p: No such file or directory
C:\home\faggot>
the illusion is so compelling! the only thing we need now is a script that crashes the computer every 30 minutes
# This is an incredibly useful function which I wholeheartedly
# recommend for regular use. I forgot where the idea came from.
# Works on Zsh. Does not work elsewhere, AFAIK.
function windows() {
clear
echo -e "Microsoft Windows 2000 [Version 5.00.2195]\n(c) Microsoft Corporation, 1985-2000.\n"
function precmd() {
PWD=$(pwd)
PWD=${PWD/\/usr/\/Program Files}
PWD=${PWD/\/home\/$(whoami)/\/Documents and Settings\\Administrator}
PWD=${PWD/\/home/\/Documents and Settings}
PWD=${PWD/\/sbin/\/Windows}
export PS1="C:${PWD//\//\\}> "
}
}
let's see how long it takes before someone ports it to bash
Name:
Anonymous2012-06-22 11:19
>>55 PROMPT_COMMAND='WINPWD=$(echo "$PWD" | sed -e"s/\(.*[^\/]\)$/\1\//" -e"s!$HOME\/!\/Documents and Settings/Administrator\/!" -e"s/\/home\//\/Documents and Settings\//" -e"s/^\/usr\//\/Program Files\//" -e"s/\/s\?bin\//\/Windows\//" -e"s/\(.*\)\/$/\1/" -e"s/\//\\\\/g")'
Substitute this in >>47
Name:
Anonymous2012-06-22 15:41
Ruby user here, #2 is preferred. Because half the shit you need typically can be expressed as TypeError, ArgumentError, etc... anything special can be given an additional Error message to separate it out, so you can just
rescue StandardError => err
if err.message.include? "Fuck You" then
# Handle fuck you exception
else
# Handle some other exception
end
end
Name:
Anonymous2012-06-22 16:56
>>57
Matching text in error messages when handling errors? Even Perl programmers don't do that.
You have transcended my preconceptions of Ruby user unprofessionalism with your code example.
Name:
Anonymous2012-06-23 2:56
>>58 Matching text in error messages when handling errors?