diff --git a/custom-skills/32-notion-writer/code/scripts/notion_writer.py b/custom-skills/32-notion-writer/code/scripts/notion_writer.py index 267490d..f0a1dbd 100644 --- a/custom-skills/32-notion-writer/code/scripts/notion_writer.py +++ b/custom-skills/32-notion-writer/code/scripts/notion_writer.py @@ -976,8 +976,9 @@ Examples: except APIResponseError as exc: print(f"Error: {compat.explain_api_error(exc, formatted_id)}") sys.exit(1) - if local_imgs: - append_to_page(notion, page_id, _upload_blocks_for(local_imgs)) + if local_imgs and not append_to_page(notion, page_id, _upload_blocks_for(local_imgs)): + print("❌ Text was written but image append failed") + sys.exit(1) print("✅ Successfully wrote content to page (markdown engine)") print(f" https://notion.so/{formatted_id.replace('-', '')}") return @@ -990,7 +991,9 @@ Examples: if not blocks: print("No content to write") sys.exit(1) + print(f"{'Replacing' if args.replace else 'Appending'} content to page...") if args.replace and not clear_page_content(notion, page_id): + print("❌ Failed to write content") sys.exit(1) if append_to_page(notion, page_id, blocks): print("✅ Successfully wrote content to page") @@ -1080,22 +1083,24 @@ Examples: ntn_files.preflight() md_body, local_imgs = extract_local_images(md_content) md_body = md_translate.translate(md_body) - parent = compat.build_data_source_parent(data_source_id) mc = _md_client() try: if args.upsert_by and existing: compat.replace_markdown(mc, existing['id'], md_body, allow_deleting=args.allow_deleting) - update_page_properties(notion, existing['id'], properties) + if not update_page_properties(notion, existing['id'], properties): + sys.exit(1) new_id = existing['id'] else: + parent = compat.build_data_source_parent(data_source_id) result = compat.create_page_markdown(mc, parent, properties, md_body) new_id = result['id'] except APIResponseError as exc: print(f"Error: {compat.explain_api_error(exc)}") sys.exit(1) - if local_imgs: - append_to_page(notion, new_id, _upload_blocks_for(local_imgs)) + if local_imgs and not append_to_page(notion, new_id, _upload_blocks_for(local_imgs)): + print("❌ Text was written but image append failed") + sys.exit(1) print("✅ Successfully wrote database row (markdown engine)") print(f" https://notion.so/{new_id.replace('-', '')}") return