package mypackage_test import ( . "gopkg.in/check.v1" ) func (s *MySuite) TestSomeFunction(c *C) { result := SomeFunction(5) c.Assert(result, Equals, 10) }
#includeThis example defines a function that throws an error using the `error_throw` macro, and a main function that calls that function within an error-catching block. If an error is thrown, the `error` block will execute and print the error message.#include "cerror.h" void function_with_error() { error_throw("Something went wrong"); } int main() { printf("Starting program\n"); error_catch { function_with_error(); } error { printf("Caught error: %s\n", error_message(error)); } printf("Program finished\n"); return 0; }