EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Callbacks return an error or thow an exception?

Also by EldoS: CallbackDisk
Create virtual disks backed by memory or custom location, expose disk images as disks and more.
#22014
Posted: 10/15/2012 15:43:24
by Rich Van Gaasbeck (Standard support level)
Joined: 12/07/2010
Posts: 11

In the help file, the callback functions for C++ are defined to return an error:

[C++ (Lib)]
typedef Error (*CBDiskWriteFileFunc)( CBDisk* Sender, LongLongWord Offset, void* Buffer, unsigned long Count);

In the MemDisk.cpp sample code, the callbacks return void. The sample implementation throws an exception on error.

void CallbackWrite(CBDisk *Sender, LongLongWord Offset, Pointer Buffer, LongWord Count);
{
...
throw new ECBDiskError(ERROR_HANDLE_EOF);
}

Which is correct?
#22023
Posted: 10/15/2012 23:48:18
by Eugene Mayevski (EldoS Corp.)

Thank you for pointing at the issue. The declaration is incorrect (this is a leftover of the previous version). Right declaration is:

Code
typedef void (*CBDiskWriteFileEvent)( CBDisk* Sender, LongLongWord Offset, void* Buffer, unsigned long Count);


Exception must be thrown in case of error.

We've fixed documentation.


Sincerely yours
Eugene Mayevski
#22035
Posted: 10/16/2012 13:57:32
by Rich Van Gaasbeck (Standard support level)
Joined: 12/07/2010
Posts: 11

When I get an error, at the end of CallbackRead() I:

Code
throw new ECBDiskError(ERROR_READ_FAULT);

And I get unhandled exception. Am I doing it wrong?
#22036
Posted: 10/16/2012 14:52:50
by Eugene Mayevski (EldoS Corp.)

Emm, where do you get unhandled exception? Exceptions are caught by the code, which calls your callbacks. If you check the source code of CPP\CBDisk.cpp near line 685 (HandleWriteFile method), you will see this yourself.


Sincerely yours
Eugene Mayevski
#22039
Posted: 10/16/2012 15:53:47
by Rich Van Gaasbeck (Standard support level)
Joined: 12/07/2010
Posts: 11

Oh, I think I'm having a license ticket issue. The download I installed only has the .lib, .h and .sys; no source. My control center isn't showing a 2.x download, so I picked up the eval version.
#22044
Posted: 10/17/2012 01:16:36
by Eugene Mayevski (EldoS Corp.)

Quote
Rich Van Gaasbeck wrote:
My control center isn't showing a 2.x download


Fixed.


Sincerely yours
Eugene Mayevski
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

Topic viewed 4257 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!