#!/usr/bin/env python
# -*- coding: utf-8 -*-

'''
Exceptions for Profile objects.
'''


class BadProcess(Exception):
    '''
    Error finding pid supplied.
    '''    
    def __init__(self, pid):
        self.pid = pid

    def __str__(self):
        msg = "No process <%s>" % self.pid
        return msg


class EmptyNtlnkMsg(Exception):
    '''
    Netlink message returned an empty response.
    '''
    def __init__(self, func, pid):
        self.func = func
        self.pid = pid

    def __str__(self):
        msg = "Process <%s> returned an empty netlink response" % self.pid
        return msg


class StructParseError(Exception):
    '''
    Error parsing netlink struct.
    '''
    def __init__(self, func, pid):
        self.func = func
        self.pid = pid

    def __str__(self):
        msg = "Error parsing process <%s> netlink struct" % self.pid
        return msg


class NetlinkError(Exception):
    '''
    Message returned an netlink error response.
    '''
    def __init__(self, pid):
        self.pid = pid

    def __str__(self):
        msg = "Error message returned from netlink <%s>" % self.pid
        return msg

@@ -40,16 +40,28 @@
 -8 -*-%0A%0A
+import os%0A%0A%0A
 '''%0AExce
@@ -825,30 +825,8 @@
  = %22
-Error parsing process 
 %3C%25s%3E
@@ -983,32 +983,39 @@
 f __init__(self,
+ errno,
  pid):%0A        s
@@ -1032,90 +1032,107 @@
 pid%0A
-%0A    def __str__(self):%0A        msg = %22Error message returned from netlink %3C%25s%3E%22 %25
+        self.err = os.strerror(-errno)%0A%0A    def __str__(self):%0A        msg = %22%25s %3C%25s%3E%22 %25 (self.err,
  sel
@@ -1128,32 +1128,33 @@
 lf.err, self.pid
+)
 %0A        return 

verbose message for errno