<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_sizelimit(size_limit, bytes_written, total_size):
 """Check if size limit was exceeded. :param size_limit: The size limit. :param bytes_written: The total number of bytes written. :param total_size: The total file size. :raises invenio_files_rest.errors.UnexpectedFileSizeError: If the bytes written exceed the total size. :raises invenio_files_rest.errors.FileSizeError: If the bytes written are major than the limit size. """

    if size_limit is not None and bytes_written > size_limit:
        desc = 'File size limit exceeded.' \
            if isinstance(size_limit, int) else size_limit.reason
        raise FileSizeError(description=desc)

    # Never write more than advertised
    if total_size is not None and bytes_written > total_size:
        raise UnexpectedFileSizeError(
            description='File is bigger than expected.')