Jump to content




CCatch - Error catching and handling made easy

api computer lua

  • This topic is locked This topic is locked
9 replies to this topic

#1 NDFJay

  • Members
  • 216 posts
  • LocationLeeds, England

Posted 16 February 2013 - 05:56 AM

Posted Image

Ever wanted to make a real working BSoD? or just catch and resolve errors before your program crash's? or maybe just display a custom screen if your program crash's calling the user an idiot for messing with the code?


Well now you can! easily!

This API is made to make it easier to catch and resolve errors and display custom error screens!


--Note! This API was inspired by theoriginalbit 's Handling and BSoD tutorial found here

Features:
  • Backwards compatible CC1.3+
  • Functions for both Advanced Computers and Standard Computers
  • Pre-designed error screens
  • Custom error screens
  • Custom crash handle functions
  • Colour and non colour support
  • Save error log to custom directory function
  • C# style error catching function for C# style main functions
Usage:
Spoiler

Coming Soon:
  • Custom logo printing and positioning
  • Email error report
Download:

#2 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 16 February 2013 - 06:42 AM

Wow what a logo ! :P Anyways looks really great ! You are really good, I think you have experienced coding before cc, no ?

#3 NDFJay

  • Members
  • 216 posts
  • LocationLeeds, England

Posted 16 February 2013 - 06:50 AM

View Postbjornir90, on 16 February 2013 - 06:42 AM, said:

Wow what a logo ! :P Anyways looks really great ! You are really good, I think you have experienced coding before cc, no ?

Haha, I may have done Graphics design in the past :P haha and thanks :) I have dont some coding before CC yes, a little bit of C++, mainly web platforms though

#4 bjornir90

  • Members
  • 378 posts
  • LocationFrance

Posted 16 February 2013 - 06:55 AM

View PostNDFJay, on 16 February 2013 - 06:50 AM, said:


Haha, I may have done Graphics design in the past :P/> haha and thanks :)/> I have dont some coding before CC yes, a little bit of C++, mainly web platforms though
You should be learning really fast so :)

#5 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 16 February 2013 - 07:10 AM

Quite useful :3 Nice Api :P/>

EDIT:

I'm busy adding this to my program and it's kind of not working :<

I'm using the A_saveCrash function for my program with a table looking like this:
local t_ErrorLog = {
	"Oh No! It looks like";
	"ComputerCraft YouTube has crashed!";
	"";
	"Error Code:";
	"(error)";
	"";
	"Please report this error code to remiX";
	"if this is no fault of your own,";
	"otherwise state what you have changed."
}

And I'm calling it like this:
CCrash.A_saveCrash( controlPanel, "center", colours.red, colours.white, t_ErrorLog, 1, screenY-1, sourceFolder, 'errorLog.txt' )

And the result is shown in the attachment.
It looks like on this line:
"Please report this error code to remiX";
it's also replacing 'error' but I don't understand why because it should look for "(error)"

Also: The error file that it's supposed to write the error to doesn't get created.

#6 NDFJay

  • Members
  • 216 posts
  • LocationLeeds, England

Posted 19 February 2013 - 09:33 AM

View PostremiX, on 16 February 2013 - 07:10 AM, said:

--snip--

Sorry for the late reply... been at work all day and havent been on the internet all weekend...

the issue was a syntactical error on my part... fixed it now new download link

pastebin get Q07qDtje CCatch

or pastebin.com/Q07qDtje

in your table replace "(error)" with ":error:", I tested it with your table and syntax and it works perfectly

#7 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 19 February 2013 - 01:45 PM

you didn't update the link for the pastebin in OP properly. You just updated the text ;) :P

Oh btw looks good :)

one suggestion, this is a better way for centre printing text
term.setCursorPos( math.floor( screenWidth / 2 - #msg / 2 + (#msg % 2 and 0 or 1) ), y )
this means that the text is put in the middle when even, and 1 pixel to the right when odd, both then appear to be perfectly in the middle ;) ... I've found this works because of how computer have an odd amount of pixels.

#8 NDFJay

  • Members
  • 216 posts
  • LocationLeeds, England

Posted 19 February 2013 - 06:34 PM

View PostTheOriginalBIT, on 19 February 2013 - 01:45 PM, said:

you didn't update the link for the pastebin in OP properly. You just updated the text ;) :P

Oh btw looks good :)

one suggestion, this is a better way for centre printing text
term.setCursorPos( math.floor( screenWidth / 2 - #msg / 2 + (#msg % 2 and 0 or 1) ), y )
this means that the text is put in the middle when even, and 1 pixel to the right when odd, both then appear to be perfectly in the middle ;) ... I've found this works because of how computer have an odd amount of pixels.

Damn I didnt even realise! haha and thanks for the tip :) I shall add it in ^_^ when I get back from work that is lol

#9 rhysjack7

  • Members
  • 41 posts

Posted 15 April 2013 - 06:16 AM

Please Can I Use It As A Bootloader For CraftdowsOS

#10 NDFJay

  • Members
  • 216 posts
  • LocationLeeds, England

Posted 15 April 2013 - 06:43 AM

View Postrhysjack7, on 15 April 2013 - 06:16 AM, said:

Please Can I Use It As A Bootloader For CraftdowsOS

This isnt a bootloader, if you want a bootloader look for NBOOT+ if you want to use this for crash handling within the OS the by all means, go for it





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users