How Do You Throw Mel-style Errors In Python?

Is there a way to throw a specific, more human-readable error in Python? Basically, I'm looking for the Python equivalent of the MEL command 'error' so that it just prints the error message over a red background in the status line and halts execution of the script.

I know I can use raise, but calling 'raise "some error"' prints something like:
# Error: None# Traceback (most recent call last):# File "", line 1, in # some error

which is hardly something a user is going to want to read if there's an error. Something like:
// Error: some error

would be much nicer. Any way to do that?

here you go...

CODE
import maya.OpenMaya as OpenMaya
OpenMaya.MGlobal.displayError('some error')

QUOTE(visualfx @ 09/16/08, 08:33 PM) [snapback]291797[/snapback]
here you go...

Ah, great. I didn't realize you could call API functions like that. That method doesn't interrupt execution, though. Is there a way to halt execution of a script, regardless of which portion is being executed?

if you want to use real Exception-based control of your script flow, why not use both then?

CODE
import maya.OpenMaya as OpenMaya

try:
    # your regular python code
    print "doing ok"
    print "still doing ok"

    raise Exception("something got wrong")

    print "this will not be executed"
except  Exception,e:
    OpenMaya.MGlobal.displayError(e)
else:
    print "finished successfully"

Exception based execution flow can be much more complex than that (nesting try...finally, try..except for initializing/finalizing parts of code), but just nesting the whole script into "try... except" and catching the generic exception and the end might be just what you're looking after.