anchor.diff:  
   %% This is crap...
   do_format_msg(_, _) ->
  -    format_tab("** unknown entry in log file\n\n", []).
  +    {error, format_tab("** unknown entry in log file\n\n", [])}.
   
   do_format_msg(TimeStamp, {V3Hdr, ScopedPdu}, AddrStr, Mib) ->
  -    case (catch snmp_pdus:dec_scoped_pdu(ScopedPdu)) of
  +    try snmp_pdus:dec_scoped_pdu(ScopedPdu) of
   	ScopedPDU when is_record(ScopedPDU, scopedPdu) -> 
   	    Msg = #message{version = 'version-3',
   			   vsn_hdr = V3Hdr,
   			   data    = ScopedPDU},
  -	    f(ts2str(TimeStamp), "", Msg, AddrStr, Mib);
  -	{'EXIT', Reason} ->
  -	    format_tab(
  -	      "** error in log file at ~s from ~s ~p\n\n",
  -	      [ts2str(TimeStamp), AddrStr, Reason])
  +	    try f(ts2str(TimeStamp), "", Msg, AddrStr, Mib) of
  +                {ok, _} = OK ->
  +                    OK
  +            catch
  +                FormatT:FormatE ->
  +                    format_error("format scoped pdu",
  +                                 TimeStamp, AddrStr, FormatT, FormatE)
  +            end
  +    catch
  +        DecT:DecE ->
  +            format_error("decode scoped pdu", 
  +                         TimeStamp, AddrStr, DecT, DecE)
       end;
   do_format_msg(TimeStamp, Packet, AddrStr, Mib) ->
  -    case (catch snmp_pdus:dec_message(binary_to_list(Packet))) of
  +    try snmp_pdus:dec_message(binary_to_list(Packet)) of
   	Msg when is_record(Msg, message) ->
  -	    f(ts2str(TimeStamp), "", Msg, AddrStr, Mib);
  -	{'EXIT', Reason} ->
  -	    format_tab("** error in log file ~p\n\n", [Reason])
  -    end.
  -    
  +	    try f(ts2str(TimeStamp), "", Msg, AddrStr, Mib) of
  +                {ok, _} = OK ->
  +                    OK
  +            catch
  +                FormatT:FormatE ->
  +                    %% Provide info about the message
  +                    Extra = 
  +                        case Msg#message.version of
  +                            'version-3' ->
  +                                #v3_hdr{msgID            = ID,
  +                                        msgFlags         = Flags,
  +                                        msgSecurityModel = SecModel} = 
  +                                    Msg#message.vsn_hdr,
  +                                SecLevel = snmp_misc:get_sec_level(Flags),
  +                                f("msg-id: ~w, sec-level: ~w, sec-model: ~w", 
  +                                  [ID, SecLevel, sm2atom(SecModel)]);
  +                            _ -> %% Community
  +                                f("community: ~s", [Msg#message.vsn_hdr])
  +                        end,
  +                    format_error(f("format ~p message; ~s", 
  +                                   [Msg#message.version, Extra]),
  +                                 TimeStamp, AddrStr, FormatT, FormatE)
  +            end
  +    catch
  +        DecT:DecE ->
  +            format_error("decode message", 
  +                         TimeStamp, AddrStr, DecT, DecE)
  +
  +    end.
  +
  +sm2atom(?SEC_ANY) -> any;
  +sm2atom(?SEC_V1)  -> v1;
  +sm2atom(?SEC_V2C) -> v2c;
  +sm2atom(?SEC_USM) -> usm;
  +sm2atom(_)        -> unknown.
  +
   do_format_msg(TimeStamp, SeqNo, {V3Hdr, ScopedPdu}, AddrStr, Mib) ->
  -    case (catch snmp_pdus:dec_scoped_pdu(ScopedPdu)) of
  +    try snmp_pdus:dec_scoped_pdu(ScopedPdu) of
   	ScopedPDU when is_record(ScopedPDU, scopedPdu) -> 
   	    Msg = #message{version = 'version-3',
   			   vsn_hdr = V3Hdr,
   			   data    = ScopedPDU},
  -	    f(ts2str(TimeStamp), sn2str(SeqNo), Msg, AddrStr, Mib);
  -	{'EXIT', Reason} ->
  -	    format_tab(
  -	      "** error in log file at ~s from ~s ~p\n\n",
  -	      [ts2str(TimeStamp), sn2str(SeqNo), AddrStr, Reason])
  +	    try f(ts2str(TimeStamp), sn2str(SeqNo), Msg, AddrStr, Mib) of
  +                {ok, _} = OK ->
  +                    OK
  +            catch
  +                FormatT:FormatE ->
  +                    format_error("format scoped pdu",
  +                                 TimeStamp, SeqNo, AddrStr, FormatT, FormatE)
  +            end
  +    catch
  +        DecT:DecE ->
  +            format_error("decode scoped pdu",
  +                         TimeStamp, SeqNo, AddrStr, DecT, DecE)
       end;
   do_format_msg(TimeStamp, SeqNo, Packet, AddrStr, Mib) ->
  -    case (catch snmp_pdus:dec_message(binary_to_list(Packet))) of
  +    try snmp_pdus:dec_message(binary_to_list(Packet)) of
   	Msg when is_record(Msg, message) ->
  -	    f(ts2str(TimeStamp), sn2str(SeqNo), Msg, AddrStr, Mib);
  -	{'EXIT', Reason} ->
  -	    format_tab(
  -	      "** error in log file ~s from ~s ~p\n\n",
  -	      [ts2str(TimeStamp), sn2str(SeqNo), AddrStr, Reason])
  -    end.
  -    
  -    
  -%% format_msg({TimeStamp, {V3Hdr, ScopedPdu}, {Addr, Port}}, 
  -%% 	   Mib, Start, Stop) ->
  -%%     format_msg({TimeStamp, {V3Hdr, ScopedPdu}, Addr, Port}, 
  -%% 	      Mib, Start, Stop);
  -%% format_msg({TimeStamp, {V3Hdr, ScopedPdu}, Addr, Port}, 
  -%% 	  Mib, Start, Stop) ->
  -%%     case timestamp_filter(TimeStamp, Start, Stop) of
  -%%         true ->
  -%%             case (catch snmp_pdus:dec_scoped_pdu(ScopedPdu)) of
  -%%                 ScopedPDU when record(ScopedPDU, scopedPdu) -> 
  -%%                     Msg = #message{version = 'version-3',
  -%%                                    vsn_hdr = V3Hdr,
  -%%                                    data    = ScopedPDU},
  -%%                     f(ts2str(TimeStamp), Msg, Addr, Port, Mib);
  -%%                 {'EXIT', Reason} ->
  -%%                     format_tab("** error in log file at ~s from ~p:~w ~p\n\n", 
  -%% 			       [ts2str(TimeStamp), ip(Addr), Port, Reason])
  -%%             end;
  -%%         false ->
  -%%             ignore
  -%%     end;
  -%% format_msg({TimeStamp, Packet, {Addr, Port}}, Mib, Start, Stop) -> 
  -%%     format_msg({TimeStamp, Packet, Addr, Port}, Mib, Start, Stop);
  -%% format_msg({TimeStamp, Packet, Addr, Port}, Mib, Start, Stop) ->
  -%%     case timestamp_filter(TimeStamp, Start, Stop) of
  -%%         true ->
  -%%             case (catch snmp_pdus:dec_message(binary_to_list(Packet))) of
  -%%                 Msg when record(Msg, message) ->
  -%%                     f(ts2str(TimeStamp), Msg, Addr, Port, Mib);
  -%%                 {'EXIT', Reason} ->
  -%%                     format_tab("** error in log file ~p\n\n", [Reason])
  -%%             end;
  -%%         false ->
  -%%             ignore
  -%%     end;
  -%% format_msg(_, _Mib, _Start, _Stop) ->
  -%%     format_tab("** unknown entry in log file\n\n", []).
  +	    try f(ts2str(TimeStamp), sn2str(SeqNo), Msg, AddrStr, Mib) of
  +                {ok, _} = OK ->
  +                    OK
  +                        
  +            catch
  +                FormatT:FormatE ->
  +                    %% Provide info about the message
  +                    Extra = 
  +                        case Msg#message.version of
  +                            'version-3' ->
  +                                #v3_hdr{msgID            = ID,
  +                                        msgFlags         = Flags,
  +                                        msgSecurityModel = SecModel} = 
  +                                    Msg#message.vsn_hdr,
  +                                SecLevel = snmp_misc:get_sec_level(Flags),
  +                                f("msg-id: ~w, sec-level: ~w, sec-model: ~w", 
  +                                  [ID, SecLevel, sm2atom(SecModel)]);
  +                            _ -> %% Community
  +                                f("community: ~s", [Msg#message.vsn_hdr])
  +                        end,
  +                    format_error(f("format ~p message; ~s", 
  +                                   [Msg#message.version, Extra]),
  +                                 TimeStamp, SeqNo, AddrStr, FormatT, FormatE)
  +            end
  +    catch
  +        DecT:DecE ->
  +            format_error("decode message",
  +                         TimeStamp, SeqNo, AddrStr, DecT, DecE)
  +    end.
  +
  +
  +format_error(WhatStr, TimeStamp, AddrStr, throw, {error, Reason}) ->
  +    {ok, Str} = 
  +        format_tab(
  +          "** error (~s) in log file at ~s from ~s: "
  +          "~n   ~p\n\n",
  +          [WhatStr, ts2str(TimeStamp), AddrStr, Reason]),
  +    {error, Str};
  +format_error(WhatStr, TimeStamp, AddrStr, T, E) ->
  +    {ok, Str} = 
  +        format_tab(
  +          "** error (~s) in log file at ~s from ~s: "
  +          "~n   ~w: ~p\n\n",
  +          [WhatStr, ts2str(TimeStamp), AddrStr, T, E]),
  +    {error, Str}.
  +
  +format_error(WhatStr, TimeStamp, SeqNo, AddrStr, throw, {error, Reason}) ->
  +    {ok, Str} = 
  +        format_tab(
  +          "** error (~s) in log file at ~s~s from ~s: "
  +          "~n   ~p\n\n",
  +          [WhatStr, ts2str(TimeStamp), sn2str(SeqNo), AddrStr, Reason]),        
  +    {error, Str};
  +format_error(WhatStr, TimeStamp, SeqNo, AddrStr, T, E) ->
  +    {ok, Str} = 
  +        format_tab(
  +          "** error (~s) in log file at ~s~s from ~s: "
  +          "~n   ~w, ~p\n\n",
  +          [WhatStr, ts2str(TimeStamp), sn2str(SeqNo), AddrStr, T, E]),        
  +    {error, Str}.
  +
   
   f(TimeStamp, SeqNo, 
     #message{version = Vsn, vsn_hdr = VsnHdr, data = Data}, 
  
positive.code:             MiniMib = snmp_mini_mib:create(Mibs),
  	    Write = fun(X) -> 
  			    case format_msg(X, MiniMib, Start, Stop) of
  				{ok, S} ->
  				    io:format(Fd, "~s", [S]);
  				_ ->
  				    ok
  			    end
  		    end,
              Res = (catch loop(disk_log:chunk(Log, start), Log, Write)),
  	    snmp_mini_mib:delete(MiniMib), 
              file:close(Fd),
              Res;
  
negative.code: 	end,
      format_tab(
        "~w ~s - ~s [~s]~s ~w\n~s",
        [Class, AddrStr, HdrStr, TimeStamp, SeqNo, Vsn, Str]);
  f(TimeStamp, SeqNo, Msg, AddrStr, _Mib) ->
      io:format("<ERROR> Unexpected data: "
                "~n   TimeStamp: ~s~s"
                "~n   Msg:       ~p"
                "~n   AddrStr:   ~p"
                "~n", [TimeStamp, SeqNo, Msg, AddrStr]),
      throw({error, 'invalid-message'}).
  
  f(F, A) ->
      lists:flatten(io_lib:format(F, A)).
  
  
  ipPort2Str(Ip, Port) ->
      snmp_conf:mk_addr_string({Ip, Port}).
  
  %% Convert a timestamp 2-tupple to a printable string
  %%
  